People talk about writing what you know. They talk about finding something you know about and write. I think it is about writing what you are interested in or have no idea about. Researching about things can be part of the writer's journey. Writing about pirates learn nautical terms, writing about a carpenter pick up a hammer, writing about a murder mystery. . . be mysterious.
Walk into a room and just say, "I am mysterious." If you are writing a nonfiction book, I think this all can be taken differently. If you are writing a fiction book, just go with it. Let you characters guide the story.
The first time I had this happen writing, I could not believe it. I had created this amazing character that I would even want to date, and she only lasted a chapter. I was sad to see her go, but hey, writing happens. My characters went another direction, and it all worked out in the end.