The mountains are both a barrier and the cause for the rain to fall in the first place. The winds that carry the rain clouds come form one direction or the other (depending on where it's located on Earth). As the rain clouds are forced upward against the mountain face, they cool and the water vapor collects and falls from the clouds as precipitation. All the water content of the clouds are exhausted in rain with no water content left once the clouds cross the barrier of mountains.
Look at Kauai the furthest west island of the Hawaiian chain. The north and west side is green and tropical from the rainfall, yet the south and east sides of Kawaii is almost a desert with practically no rainfall whatsoever - and this is an island 40 miles across, half tropical, half desert due to the same geologic/climatological reason.