Can a 60 W heater be used on a 40 W unit?
Yes, you can, I used various heater cartridges with different powers ranging from 40-80 W.
Where you need to look out for is that heating is not too fast that you get overshoots such that it triggers alarms, see PID tuning 50 W cartridge in Marlin. It is best to PID tune the hotend heater once you replaced it with a new cartridge.
It extends about 5 millimeters beyond my heating block. Can it be used in general or will it lead to some consequences?
Try to center it better, do note that the heat is produced by a wound resistor wire, it usually doesn't extend all the way to the end of the heater cartridge.
Image taken from Vsec Temperature Sensor Manufacturer