I did it both ways. I was working in semiconductor industry as a Mech Eng for 8 years, slowly drifted towards software in my own time and at work. Switched to Software engineering officially at a quantum computing startup, built Fab software, managed databases, worked on wafer layout tools, wrote APIs, front end apps, metrology interfaces. I switched back to Hardware engineering (with some FPGA dev) in the space industry 6 months ago.
Overall, I was impressed by how modern software is built, engineering that goes into it and satisfaction from immediate gratification. I had amazing mentors. Since I am back to Hardware, things appear a lot slower, but having a software background is huge. I have working knowledge of the entire stack from load balancers to interface arbitrators at the FPGA level. I can design PCBs to database schemas. I honestly feel like I can build anything and everything.