Yes- layoffs typically happen for bigger reasons than just performance. It is a bit of a red flag, I mean clearly you were not the most critical person the company could not do without, but its happened to me and it has not been an issue. In a struggling company, layoffs can happen for many reasons including- being too junior, being too senior (costing too much), working on a feature/product that is getting killed- its a lot easier to just cut everyone on that project then to start cherry picking them and moving them, disagreeing with the strategy, and sometimes there is just a mandate to cut 20% and your team could all be great people and its just a tough decision to make...
Dipping back in? Just code. Take some free classes on webdev, contribute to open source, build a portfolio of projects you can show off, you will get your foot in the door somewhere that might be a little crappy, but after a year or two it should be much easier for you to at least get a shot at a FAANG or a much better company.