It does not matter what time of day you eat, as long as you eat no more calories than you burn, you will not gain weight. If you eat fewer calories than you burn, you will lose weight. If you eat more calories than you burn, you will gain weight.
Eating three meals a day at the same time each day can have other benefits in life, but snacks at night are no worse than snacks in the morning or afternoon.
Also, It is mathematically easier to lose weight than to gain weight. If you eat 3,500 calories more than you burn, you will gain 0.3 pounds, but if you burn 3,500 calories more than you eat, you will lose 1 pound.