Literally, this idiom means, "to be destroyed by one’s own bomb." (A petard was used to break down a door or wall.)
When one is caught by something made and intended to catch another, this is said to have happened, though it doesn’t seem to be a very common expression any longer.