Both 'stitch' and 'tuck' contain the notion of something completely confined or enclosed. In stitching, the garment is completed, with hems folded and sewn neatly together; in tucking - in the sense of putting to bed - the child is also hemmed in, with loose edges pushed away out of sight/reach.
In the figurative senses you refer to, the idea is that someone has utterly got the better of you, leaving you in no position to 'move'.
There are other similar sayings, such as 'done up like a kipper', with the same concept underlying them. Once a herring has been transformed into a kipper, it hasn't got much hope of ever being a herring again! It is totally undone, as it were.