spawn the following:
wooden frame
2 small storage batteries
1 welder
1 [vehicle] battery compartment mod
install the battery compartment mod into the welder, then install one of the small storage batteries into the welder.
set up the wooden frame as a vehicle, then try to install a small storage battery (remember you have 1 more in inventory) into the frame.
Notice that it steals the storage battery from your welder rather than using the one in your inventory.
I'd guess that it's caused by the part installer not ignoring batteries installed into tools
It probably also happens with medium storage batteries too, though I haven't tested this.
Where this becomes a problem is when you want to keep in your welder the larger charge, but it instead steals it for the vehicle. You have to drop the welder before you install it which gets awkward if you're also doing repairs or installs that require a welder and you forget about this bug.
This is true of pretty much any vehicle part, outside of stealing from the tool. If you want to take off a damaged part from a car and install a new one you have to take the old part off, walk several tiles away, drop the old part, come back, and only then install the new one. That is because if there are several choices the one it picks is arbitrary. The only rule is distance, but if you have several parts in your inventory? Or in a single pile in the ground? It'll install one pretty much at random.
Confirming this but with different items.
Crafted a heavy rail rifle and it needs an UPS conversion mod. It stole it from a food dehydrator that was 1 tile away. Same tile had also free UPS conversion mods and it still stole from the dehydrator.
The food dehydrator was fully charged and after it lost its ups conversion mod, the charges turned into normal battery charges.
I can confirm that this is still occurring in version 0.C-26451-g7399448, build 7153.
Still occuring in version: 0.D-3024-gca988b5b90
Cannot reproduce in 0.E-6177-g 9f4a1b841d
Wood-frame vehicle with battery just installed:

Modded arc welder retains its battery:

Closing issue.
Most helpful comment
Confirming this but with different items.
Crafted a heavy rail rifle and it needs an UPS conversion mod. It stole it from a food dehydrator that was 1 tile away. Same tile had also free UPS conversion mods and it still stole from the dehydrator.
The food dehydrator was fully charged and after it lost its ups conversion mod, the charges turned into normal battery charges.