The resource of any node and unit of the car is limited. It is different for different models and brands, but it is. This means that after some time or some mileage, it will fail and the question will inevitably arise of its replacement or repair. A car engine is no exception. Of course, if major repairs are inexpensive, then it makes sense to do this. If the car is quite rare or old, then you may need to replace the engine, because the original parts are difficult to find for various reasons.

The whole engine is much easier to find. In addition, in this case, there is no need for disassembly and troubleshooting, which takes quite a lot of time. Recently, a law has been enacted in Russia on the abolition of checking engine numbers during inspection and registration of a vehicle. This does not mean that any engine can be installed indiscriminately on a car. This indicates that difficulties in the design should not arise. In any case, there will be much less. But do not forget that each motor has its own reference account confirming its affiliation. It is drawn up when the car is deregistered "for details", that is, separate documents for the body and the motor are issued.
In Europe and America, the engine has long been considered the same consumable item as brake pads or piston rings, so its attachment to a particular body is simply absent. At least this is not reflected in the documents.
There is another case where engine replacement may be required. But this is a pleasure for those who are seriously involved in tuning their iron horse.
This is understandable desire, because in the world there are few people who would not want to improve the dynamic characteristics of their car.
More power - higher performance. Replacing the engine with a more powerful one is performed not only in a passenger car. It can be a truck in which the capacity of the entire car depends on the power of the power unit. In this case, it is dictated solely by commercial considerations.
Replacing the engine (which runs on gasoline) with diesel is more often done in trucks. It is more economical and has better traction characteristics. Such a replacement is also practiced in cars, although with "cars" it is often the other way around: powerful engines are simply not needed by ordinary drivers. Let's say a V6 with a working volume of 3 liters will not be popular in the middle class. Replacing the engine in this case is designed to make the car more economical and reduce maintenance costs. These are the main reasons why such an operation may be required, even if it will be invoiced.
There are many more reasons and reasons for replacing the engine. The design, as described above, will now not be as complicated as before, most of the time will be spent on installation and dismantling, and again you can ride your iron horse.