Long answer, sockets may have different positions and spacing between screwes and there may be other limiting factors. If you use stock fan, just keep it on CPU you get it with. If you want to buy aftermarket fan, it should have listed support for sockets. Some manufacturers go even further by listing of support for specific motherboards and possible issues (as example noctua have very extensive compatibility list with different sockets, motherboards and even rams).
Some of there aftermarket have special mounting backplates and system which allows it to work on multiple sockets, both intel and AMD, but for that you will have check if it's compatible.