Used as an intensifier, and placed like an adjective. It literally means "confused" or "foiled". As slang, it is equivalent to "danged" or "darned". Used mostly in the southern U.S. and in Scotland.
Dagnabbit, where in the Sam Hill did you get that frickin' piece of crud? Get the confounded thing out of here!