That’s what they tell you.
I dunno, perhaps it’s a lot more fun to write what you don’t know. I’ve written two books that have, people tell me, nothing in common with one another: Regarding Avalon, a futuristic crime thriller, and Leonard Bliss and the Accountant of the Apocalypse (I’m going to have to start using an acronym for that title) which, people also tell me, is of the Magical Realism genre.
The books do have one thing in common: research, and a lot of it. Regarding Avalon’s central character suffers from Multiple Sclerosis, a condition I knew nothing about. Leonard Bliss and the Accountant of the Apocalypse needed months of background reading into the history and workings of the Roman Catholic Church. This isn’t unusual; most writers spend much of their time carrying out background research, so where does this notion come from that we should write what we know? Surely, half the fun in writing is in learning something completely new.