Check your hinge-side post to be sure it is firmly seated in the ground and level. Shake the post by hand; if it moves loosely in its hole, you need to reset it.
Remove the gate from its hinges. Use a level to stand the post upright and in proper position.
Use a narrow, “sharp shooter” spade to dig out around the post to a depth of 10 inches and about 6 inches out on all sides. Mix concrete to manufacturer's instructions and fill the hole to 3 inches below the ground.
Allow concrete to dry and fill the remainder with packed dirt. Rehang the gate.
Check your latch-side post and repair any looseness. If it moves loosely in its hole, reset it as you did for the hinge-side post.
Check the hinges to be sure all hardware is securely tightened. Loose screws or bolts should be snugged down.
Replace hardware in a wallowed out hole. Try a slightly larger screw or bolt.
If this tightens snugly, replace the remaining bolts or screws with the larger size to insure a more permanent solution.
Repair damaged areas that will not hold a fastener. Remove the hinge and shift it up or down enough to position the holes over good wood and reinstall.
Be sure to support the gate at the proper height with lumber underneath to keep it level.
Fixing the Frame
Check the gate frame. If it seems loose add a gate anti-sag kit.
It comes with 2 eyebolts, a cable and a turnbuckle.
Follow manufacturer's advice for best results. Here are the basics: Drill pilot holes for the eyebolts at the the top corner on the hinge side and the bottom-corner on the latch side of the gate frame.
Install the eyebolts and stretch the cable with the turnbuckle in the middle between the two eyebolts. Use the end clips to clip it in place.
Tighten the turnbuckle with a wrench to lift the latch side of the gate to the desired height. After a few days, check again and tighten as needed to correct any settling.