Answer :

During the day the temperature of the beach is higher than that of the ocean because water retains temperatures longer than land it stays cool in comparison due to the previous night, this makes the air over the ocean cooler in comparison to the beach which heats up much quicker when exposed to the sun, the cooler ocean air rolls inward towards the beach as the hot air from the beach rises and passes over the ocean to cool down in this cycle, heat rises and cold air settles like so. So, at night the beach cools down much quicker without exposure to the sun, and the ocean water retains the heat from the day, making the roles reverse, and switching the direction of the cycle, and changing direction of the wind.
The moon makes a gravitational pull that pulls the waves and air