Getting a piece trapped is a common part of chess.
For example maybe you have a knight in the corner which has already captured a rook but thy knight is doomed.
Most players instinctively play a kamikaze move with the trapped piece ...for example taking a pawn but still losing the piece so that they at least get a pawn.
However that is not the only option.
The other option instead of a kamikaze move is simply make a move that you actually want to do for example developing a piece.
After your opponent captures the piece low and behold its now your move again but you got to play that developing move for free yippee.
Sometimes you may wish to take the pawn instead but folks dont forget to at least consider the alternative ...a free move.