what they lacked is knowledge and a drive, a purpose, and in our real history those sweet sweet infinite electricity source, gifts of gods.
in terms of craftsmanship, materials, and other necessities they were quite well equipped to the task(IDK, think of a clock, I bet u 99 percent do not know how they were made if haven't seen Click Spring videos), they just would not know how to put it all together. really, early bronze age technologies, and methods, and materials would suffice to build a practical electric motor.
but also do not forget those famous examples that - rockets were known in ancient china and some conspiratologists/historians/MythBusters even tried some of those as weapons, which may or may not be used by Koreans(?) at that time, with low-end partial success.
A steam engine, as a toy, was known since the roman empire/Greece, but it took half a millennia or more and a different civilisation to put it to work.
There is a saying that necessity is mother of inventions, and it not necessarily mean u invent when the hard time comes, but rather one puts together what u already know in a solution which then being used, along u can invent few other things but. There are multiple examples of early births of ideas or prototypes which didn't take off until later time or died prematurely or had a hard time spreading.
Bearings, wires, magnets, casting, insulation - none of that was a problem at medieval times. Heck, they even had conveyer approaches of manufacturing long before Ford made it a thing, again circa Rome empire time at least, the mass casting(mass production in some sense) was known even before them.
what were they lacking is a system of systematic knowledge and problem-solving and knowledge proliferation en masse - which today we call science or scientific methods.
So, could they - yes, absolutely; would they - unlikely, if not handwavium, batteries alone by far is not enough.
But the scientific and industrial revolution could come a few hundred years earlier.
Having a powerful electricity source you even do not need to use it in your typical electric motors to make a motor - start directly with ion engines, lol
Weekend Project: Ionic Space Thruster
Ion Propulsion - The Plane With No Moving Parts
or some turbine water combustion setup - electrolyze water and mix it with some water stream in a pipe and sparks inside and have u trusty water spitting pipe hitting water wheel type setup. as it quite easy to observe those effects, and the mechanically inclined mind can come with a certain setup.
electricity is very powerful and flexible - the way we use it is not the only way, we try to use it efficiently as it is not free, but if one has an abundance of it and does not know better ways - there are a lot of ways of how to use it.
about repacing horses, by the way, do u know what a replacement lacks of? Autopilot, and we still didn't solve that problem, lol. Yes, sure we had gotten plenty of perks by that relacement, too many to count, but autopilot was lost for a long time, until recent years.
so even if u have motors, u have to put more benefits on a plate to convince others it is a good replacement. roads are bad, so u may forget about speed, lol. No lights on roads, forget about 24.7 driving, etc. railroads are good because they solve some of those, but it is good only where it is.