So imagine you want to throw a ball, but you accidentally throw it at yourself and it hits you in the face. That's kind of what happens when someone is hoisted with their own petard!
But what's a petard, you ask? It's actually a fancy word for a bomb or explosive device. And to hoist someone with it means to be hurt or defeated by your own plan or action.
So if you're trying to play a trick on someone, but it ends up backfiring and the joke is on you instead, you've been hoisted with your own petard! It's like when a bad guy in a movie sets a trap for the hero, but ends up falling in it themselves.
Basically, it means that the thing you intended to use against someone has ended up hurting you instead. So be careful, and think twice before you try to use a petard (or any other explosive device) against someone!