A textbook is a book published with the intention of being studied as part of a class. It could cover any kind of material: math, physics, other sciences, a foreign language, grammar of your own language, history, etc.
A technical book is a book that covers a technical topic. In my experience this mainly includes the physical sciences and engineering. Exactly what range of sciences are considered technical (biology? anthropology? sociology?) is a matter of interpretation, but I believe they are more often not considered "technical books".
You may find technical books used as textbooks for teaching technical topics, but not every technical book is a textbook, and not every textbook (especially outside the physical sciences) is a technical book.
How can we accurately define textbook and technical book such that it becomes easy to classify books into one of these two categories?
You can't. Many books are both. Many books are neither.