MOSFET power and heat dissipation
"So, the power dissipated = iiRds. So power = 0.4W. Now, applying the thermal resistance formula, we get the temperature = power*Rj. Temp = 4degrees celcius !!!!!!"

The temperature you calculated is not that actual temperature but the increase above ambient.

If the ambient is 25°C the resulting temperate would be 25 + 4 = 29°C.

Be careful about what information you are taking off the data sheet - is your example 10°C/W for junction to ambient or junction to case?  On a data sheet it will often be junction to case as they don't know what heat sink you are going to use.

You add heat sink thermal resistances to the device junction to case to get the total junction to ambient thermal resistance.

There may be a junction to ambient value as well on the data sheet for devices that don't normally have a heatsink - for small devices it can be many hundreds of degrees per Watt.  Even a package such as TO220 will have a value of 35 deg/Watt without a heat sink giving a rise of 14°C and a junction temperature of 39°C in 25° ambient for your example.

Also the worst case ambient temperature needs to be considered - this might be 50°-60° if the device is in a hot environment or an enclosure giving a max junction temperature of 64°C, quite acceptable for virtually all devices.

The maximum junction temperature for the device will be given on the data sheet and is typically 125° or even 150°C.