Writing a book is like anything else. You learn to do it by doing it.
One side benefit of writing a book is that you’ll learn the material much better than if you’d never started. So there’s that.
If you work with a publisher and editor, they’ll pressure you to make progress and submit drafts of chapters. That can be significantly motivating if you’d otherwise have trouble sticking to it.