The small-scale wind system at the coast is a result of the uneven heating rates of the land and the water.
During the day, the land heats more quickly than water. The land heating causes the air above to rise thus creating a shallow area of low pressure.
The reverse is true over the water, where a shallow area of high pressure is formed from the cooler, sinking air.
The air moves from high to low pressure resulting in winds moving from the sea toward the land (sea breeze). This sea breeze also causes cooler temperatures on the beaches, because the air over the water is cooler.
Also, the sea breeze can act like a mini-cold front which can actually generate and push thunderstorms inland.
Not surprisingly these are referred to as sea breeze thunderstorms.
During the night, the land cools faster than the water, so now high pressure is over the land and low pressure is over the water causing the winds to flow from the land to sea (land breeze).