The only reason I have my job that I do now is because of side projects. How else are you suppose to learn different parts of the stack when you're (usually) only hired to work in one part? How are you suppose to learn DevOps/CloudOps unless you're on an Ops team? Many (most?) companies don't delegate full stack responsibilities to individual teams.
If you're doing a huge career change, side projects may be your only way. But most companies (in my experience at least) recognize the value in having their application developers understand some Ops work, and vise versa.
Many (most?) companies won't entirely "firewall" you from other groups. Even if you're throwing an application over the wall to ops, there's usually opportunities to learn from them, help out on specific tasks, etc.
That said, learning at work is probably _better_, but I do think side projects with a specific goal (e.g. to learn a technology) are a valuable supplement.