Weight gainers work by providing your body with a surplus of calories and protein.
Of course, you need extra calories to gain weight, while protein is essential for growing and maintaining muscle mass.
They're mostly taken in the form of a shake, which provides a convenient way to consume these extra nutrients