Someone else writing "your" book is an interesting concern, and certainly one I respect (the worry feels so real!) (it gets me right in the chest), but it is also almost never a problem. From a publisher's perspective, finding other books on a particular topic can help justify publishing a book -- it means the subject is viable in book-length form. Many publishers worry about making a book out of what should really be an article, and suffering the resulting low sales that result from producing a book that no one really wants or needs. From an author's perspective, no one else can write your book. Even if a book on your topic should appear while you're writing, that simply gives you one more interesting obstacle to push against, and (we hope) argue with. If you're lucky, it will be a book with which you disagree so thoroughly that you can have a wonderful time taking it to task. Both you and your "opponent" author will benefit from the exposure.
Firsts are overrated in publishing. What counts more is bests. Do a terrific job, and you'll be the one everyone turns to and quotes. Yes, readers can tell the difference, and just because someone beats you to the finish line doesn't mean that anyone will necessarily think they wrote the best book. My shelf is dotted with quickie treatments of the author I'm writing about. They're good books, but there is a lot they missed, and the precise one I'm writing has never been done. I don't fret a moment that it will be done, because only I can write my book, and only you can write yours.