To bring disaster on oneself by one's own words or actions; equivalent to 'to dig one's own grave' or 'to make a rod for one's own back.'
彼は会議で不用意な発言をして、結果的に墓穴を掘ってしまった。
He made an imprudent remark in the meeting and ended up digging his own grave.
事前に調べずに約束したら墓穴を掘ることになるよ。
If you promise without checking in advance, you'll be making a rod for your own back.
政治家が証拠のない批判を続ければ自ら墓穴を掘るだけだ。
If a politician continues unfounded attacks, they'll only be digging their own grave.