Confusion commonly arises around the use and contents of the foreword, the preface, and the introduction, so I have focused on them here:
Foreword: This is an endorsement of your book written by a well-known expert, the most recognizable authority on your subject you can think of. Typically it is about 500 words. You must invite this individual and get their agreement to write the foreword well before you send them the finished manuscript. In the invitation let him/her know the timeframe for the arrival of your ms. When you email the ms or mail a hard copy, remind him/her of the word count and your deadline. (You do not pay a fee for the foreword.)
Preface: This is easier to write after the book is finished — it's mostly about you. Many readers skip it. Most importantly, the preface highlights the benefits that you've decided to offer readers of your book - what will they know and/or be able to do when they turn the final page.
The preface can contain a brief description of the book's angle, philosophy, your criteria for inclusion/exclusion of material, its organization and how to read it. Many authors explain their motivation for the book's creation here and perhaps details about how they did the research.
The preface is the only place you use the first person in a nonfiction book that's not about you.
It helps when you're writing it to imagine conversing with a reader who is interested in your book's topic; tell them about it, about your passion for the project, and why you were ideal to write it. Make it a little personal too - every reader likes to get to know the author.
Introduction: This precedes the first chapter, is not part of the front matter, and is optional. It is for and about the reader.
If you opt for an intro, it's the place to hook your reader by captivating them with an offer they can't refuse; then reel them in. The intro is usually written by the author, but not necessarily, and offers a compelling overview including the purpose of the whole book and some background if appropriate to the topic. Remember that many readers skip the preface and start here.
Nonfiction back matter is much easier to handle and has fewer pitfalls. Your NF ms can include appendices, endotes, glossary, bibliography, afterword, and index (but don't prepare the index now — just mention it in your ms and proposal). And this reminds me to urge you to keep very accurate records as you write your manuscript — if you don't, you won't be able to recreate your research, cite your quotes, etc. Be diligent and the back matter will come easily.
NB: The best reference book on this topic is the Chicago Manual of Style, 16th ed., (left). Front matter starts at section 1.16; back matter starts at section 1.57.