When you have just eaten, or just drank an acidic drink like soda, juice, or Gatorade, you have just contributed to softening the outer surface of your teeth/enamel. Many people brush directly after this. But when doing so, you are essentially exfoliating a very thin layer of your teeth off, or possibly roughening up the surface.
My advice to my patients is to brush a while after the natural factors, bicarbonate in your saliva, in your mouth has taken its course to bring the acidic environment back to neutral and has given your teeth time to un-soften. Xylitol containing lozenge can promote salivary flow especially after a meal or snack. Xylitol gums have become popular over the years as well, but chewing gum can be contraindicated for people with TMJ issues. You can consult your Dentist on whether you have TMJ problems or not.
Now that we covered eating, then what about the mouth at night?