I have experienced this issue (fan randomly coming on in the night) and believe I have found both the cause and the solution and would like to share it with you.
Firstly this is to do with an inline fan system where the fan draws air out of a shower light assembly and then pushes it out...