Why do rivers sometimes travel down the opposite side of the mountains from where the rain happens?
In that image you have displayed you are assuming a 2D flow i.e. in the x and z direction where is x is the direction along the mountain range  which is parallel to the ocean(or sea) and the z is the vertical direction. This is a very simplistic assumption of mountain topography as depending on the context one can have mountain gaps and then the moisture laden winds can assume a 3D flow i.e. in the x,y,z direction( y in this case would be across the mountain). In the specific case you mention namely the Western Ghats there is the famous Palakkad Gap which bring in moisture laden winds from the Arabian Sea into rain shadow area(at least from the perspective of the South West Monsoon) and can fill up the river headwater source on the rain shadow region and these rivers then flow from west to east. 

Secondly the atmosphere is a continuously stratified fluid and in the orographic context one needs to consider what is called the Froude number. From a layman's perspective this is a ratio between the inertial forces and gravitational forces that determine the 3D state of the atmosphere.
From a perspective of the the atmospheric scientist the inertial forces in this case would be horizontal wind field(monsoonal wind) and the gravitational forces are represented by Brunt Vaisala frequency and is a angular frequency that tells you how air parcels oscillate vertically in a stratified environment.

So assuming the following 
              $$ Fr_n &lt; 1 $$
what this means the incoming wind from the ocean side is not strong enough the penetrate the mountain barrier and you can have what is called upstream blocking. Often during the monsoon the monsoon trough will spend most of it's time offshore and only give skeletal rainfall to the coastal areas. 

In the other scenario where the following applies

$$ Fr_n &gt; 1 $$ 
in this case the wind is strong enough to penetrate the mountain barrier and the capping inversion on the Lee side can be broken in many ways(diurnal sensible heating and latent heating and ample moisture) can cause dark cumulonimbus clouds to form on the Lee side and that would certain fill up the river source on the Lee side as well. 

As a case study Tamil Nadu which is not often a beneficiary of the South West Monsoon and is a rain shadow zone has had a surplus rainfall for the past two  years thanks to the principle explained above. The Thamirabharani river feeds off the South West Monsoon as it originates from the Pothigai Hills on the eastern side of the Western Ghats. 

This paper - Houze 2012 Orographic Precipitation  is comprehensive and the specific case of the OP will be covered in figure 3e/3f as well as Figure 30(unblocked flow).