At most big-box retail stores, the purpose of the egress door "security" is not to prevent customers from stealing things off the shelf, it's to prevent a form of fraud where the "purchaser" and the cashier are in cahoots.
Basically:
*Your buddy gets a job at the store as a cashier
*You go in an pick up some moderately priced, bulky items (like some mouse pads) and one relatively expensive, small item (like a large SD card)
*You to the cashier and make sure you get your buddy. If for some reason you don't, you just come back and return everything later and try again some other day.
*Your buddy rings up the bulky, moderately priced stuff, placing it in your bag, and "forgets" to ring up the expensive, small item, yet it somehow also makes its way into the bag.
*You walk out and optionally come back to return the bulky, moderately priced items. You pocket the expensive, small item or sell it for cash on e.g. eBay.
This can be thwarted by having an independent party (the door checker) verify that everything in your bags are also on your receipt. You could still attempt to place things in pockets or whatever, but that can get a bit more suspicious looking, and most retail packaging in the USA intentionally makes that difficult. Now, at least at my local Fry's, they don't really seem to actually check this very well. The door person pretty much just looks at your receipt way too quickly to actually read it, looks in your bag, marks it, and sends you on your merry way. They may be looking in the bag for items commonly susceptible to this particular fraud, though.
Obviously, you can get around this protection by having the shopper, cashier, AND door person in cahoots, but that's a lot harder. A good manager will watch out for such conflicts (having a cashier that also knows a door person personally scheduled at the same time).
FWIW, no, they generally have no authority to detain you, and you can generally decline to be searched. If they honestly believe that you did steal something, they can elect to detain you until police arrive, but if they turn out to be wrong, you can sue them for that detainment, so most loss prevention people tend to be VERY unwilling to do that. Note that some membership stores (like Costco) have you enter into a contract as part of your membership whereby you agree to such searches. Some stores also post a notice upon entry that you could be searched, and IIRC the validity of such statements varies by state (and country, of course). IANAL, yada yada.