The claim that eating late at night correlates to weight gain is partially false. According to Harvard Medical, "Eating later in the day increased participants' hunger, decreased the number of calories they burned, and promoted fat storage." They later state that over time, eating later meals could lead to weight gain. This suggests that eating late at night doesn't directly lead to weight gain, it can influence metabolism. hunger, and calorie consumption. Which can lead to weight gain.
Additionally, the University of Arkansas claims "it is not the time of day that makes the difference — it’s what you are consuming." This means that eating late at night itself isn’t necessarily the issue, but rather the types of food commonly consumed during late-night eating. Typically, the food we eat late at night consists of snack items instead of dinner meals. Moreover, snacking is usually done while watching TV, which usually leads to mindless eating, which in turn will lead to weight gain.
Sources:
https://uamshealth.com/medical-myths/does-eating-late-at-night-make-you-fat/
https://www.health.harvard.edu/staying-healthy/harvard-study-curb-late-night-eating-to-stave-off-weight-gain