I've also been told on occasion to write what I know about, but what fun is that? I have a quote that I really enjoy and I've included it here:
Write what you care about and you will evoke emotion.
Write what you know about and you will build credibility.
Write what you would like to know about and you will discover your truth.
I agree that as you research those topics you'd like to know about, you gain the knowledge you need to make a believable world for your readers. During your research, you also gain insight into yourself, others and situations you may never have realized existed before.
Perhaps the strongest books come from those writers who can research an intriguing idea enough to know the subject and care about it as they finally begin the process of putting into words for their readers.