Solenoid engines are not efficient there are a number of reasons for this, but it isn’t the fault of using electromagnetic repulsion/attraction. Electronic/Electric Motors can be made with high efficiencies, but they all convert electrical energy to a rotational movement. Solenoid engines use a reciprocating movement and then convert that into a rotational movement using rods and a crankshaft , not very efficient.
It makes a superb toy, and its great for learning about the mechanics of piston engines but it’s not the best way of producing rotary motion.
One of the sources of inefficiency is that the magnetic attraction of a solenoid (or any magnetic attraction) falls off by the square of the distance. This is why magnets are strongly attracted to each other only when they are close to each other. The problem in a solenoid engine is that ideally you would like the same force applied throughout the stroke. In practice you get a huge force at the top of the solenoid, and very little at the start of the stroke. The inefficency comes from the fact that to create the magnetic field current continues to flow in the solenoid, through out the stroke, doing nothing for most of the stroke but heating up the coil. Very little of the electrical power flowing in the coil ends up as motion in the armature/piston.
If you couple the armature through a con rod to a crank, only a very little power imparted to the coil can be used to create rotary motion. The rod and crank arrangement incurs further frictional losses, but the main loss is in the solenoid.
In our kits we try to design out as much of the inefficiencies as possible. The total movement of the armature in the solenoid is kept to a minimum, usually 8mm or so. To counter frictional losses ball bearing races are used throughout. In our 4 cylinder engines, we also use an eccentric, rather then a crank to convert the linear motion of the solenoid to rotary motion. This has proved to be more efficient for short throw engines.