How do waiters give dishes 'on the house'?
Depends on the restaurant.
Most decent restaurants have processes in place and allowances for this sort of thing. Sometimes the discretion is given to the servers, who are seen as the interface with the guest. They've spent the most time with the guest and can determine whether a dish or a drink would be appropriate, appreciated, or improve the quality of the guests' visit during something like a special event (birthday, anniversary, first time at the restaurant).
Most of the time, a manager is responsible (Chefs included) for making these sorts of decisions.
Restaurant groups that know what they're doing have a portion of their budget allocated to what we call "Comps and Voids" - a Comp can be anything from "The Guest didn't like this" to "It's their anniversary - let's send them some Champagne." Voids are considered to not have any material impact on the bottom line (i.e., the dish was rang in, perhaps incorrectly, but it wasn't made - no waste).
Bartenders should always be given "comp tabs" to take care of new guests, regulars, or others in our industry, but that's a different discussion.