The Oxford Dictionary of English Idioms says
shoot yourself in the foot inadvertently make a situation
worse for yourself; demonstrate gross incompetence
The Free Dictionary online has
Fig. to cause oneself difficulty; to be the author of one's own
misfortune. I am a master at shooting myself in the foot. Again, he
shot himself in the foot by saying too much to the press.
The Chambers Dictionary has this pithy definition
(inf) to harm one's own interests by ineptitude
The original meaning of either accidentally shooting yourself in the foot with a gun or deliberately avoiding military combat by self inflicting a severe wound seems to have been lost or fogotten.
Perhaps the idiom, to shoot oneself in the foot, has overtaken a much older saying which has slowly grown out of favour and is becoming obsolete.
Hoist with own petard
Fig. to be harmed or disadvantaged by an action of one's own which was meant to harm someone else. Based on the literal meaning of hoist by your own petard; blown into the air by your own explosive device. (From a line in Shakespeare's Hamlet.)
There's letters seal'd: and my two schoolfellows,
Whom I will trust as I will adders fang'd,
They bear the mandate; they must sweep my way
And marshal me to knavery. Let it work;
For 'tis the sport to have the enginer
Hoist with his own petar'; and 't shall go hard
But I will delve one yard below their mines
And blow them at the moon: O, 'tis most sweet,
When in one line two crafts directly meet
The Free Dictionary gives the following examples of usage. It seems to me, at least, that the meaning is very similar to "shoot oneself in the foot".
She intended to murder her brother but was hoist with her own petard when
she ate the poisoned food intended for him.
The vandals were hoist with their own petard when they tried to make an emergency call from
the pay phone they had broken.