Several methods can prevent dogs from opening cabinets: childproof locks, magnetic locks, motion-activated alarms, or placing heavy objects in front of doors.
The most effective long-term solution is training. Use positive reinforcement, such as treats or praise, to teach your dog not to open cabinets. If problems persist, consult a veterinarian or professional dog trainer.