The french used to use an explosive device called a “petard” (old french for a fart), that was used to breach doors. However these would sometimes blow back and kill the user rather than breach the door. This was the original intention for the Shakespearian phrase. One was Hoisted (old verb* not used anymore but essentially blown off their feet) by their own Petard (or door breaching bomb).
More information is here: https://en.m.wikipedia.org/wiki/Hoist_with_his_own_petard
*Unrelated to hoist as in to lift, despite similarities
🎶 Doctor, Doctor, say what you see, I’ve got a bad case of diabetes 🎶