Is it ok to switch wires from gauge 12 to 14 inside a box?
Absolutely not!  You need 12 AWG for enough wire thickness so you don't set the wires on fire.
What you should do is two things.

Use &quot;screw-and-clamp&quot; type switches and outlets.  These allow you to back-wire, but without the reliability problems of backstabs (which only take #14 anyway.
Once you have done that, if that is not enough to solve your problem, then pigtail, yes-- but with #12 stranded wire.

This is sold as individual wires called &quot;THHN&quot;.  Many shops sell it by-the-foot.
Stranded is a sheer pleasure to work with.   However, it's illegal on backstabs and almost impossible for a novice to competently put on a side screw.  So, the &quot;Screw-and-clamp&quot; devices make that work out.
If you fall in love with THHN stranded, you can use it anywhere as long as it's inside conduit.  Smurf tube, PVC or EMT metal.  If you run metal, that serves as the ground.   You can put up to 4 circuits into a conduit, and it makes it easy to do things like 3-way circuits that need always-hot and neutral for onward stuff.