After the success of Buddenbrooks, he married and fathered six children. Yet the surviving diaries tell us of recurrent sexual problems – and of Katia Mann’s extremely sympathetic response to them