I tried it again and it seems like only certain modded buildings are affected. The "Mechanical plant" from Planet Paracelsin and "Hydro plant" from Planet Maraxsis are two machines I have been able to reproduce the issue with. I haven't tested all machines, but these two revert every time I placed them and picked them back up.
For the Hydro plant, there may be some logic in Maraxsis that is causing this behavior since the machine will have either 4 or 8 module slots depending on the surface it is placed in. That logic could also affect the item that you get when you pick the Hydro plant back up. Not sure about why it could be occurring with the Mechanical plant. Other machines from that mod do not appear to have the same issue.