Apply hot glue in several places to the top of the pad and lay on your patch tucking the rim of the patch under the old carpet backing. You'll have to trim a little for a good fit. Allow the hot glue to dry. Now, get an upholstery needle and some yarn that blends with the carpet and tack the patch in place at about eight places around the rim of your patch. Trim any areas that stand high compared to surrounding carpet.
Most people replace carpet due to a few worn or stained areas.
This is not necessary if you plan ahead for repairs. Van in Alabama. Another use for vinegar. My daughter works at McDonald's and her uniform stinks from the smell of grease attached to the lovely polyester uniforms. No matter what or how I've washed her uniform, the grease odor would not leave and would sometimes make the other clothes in the washer and dryer smell.