How can a monoid be a category with just one object? My book says that:

A monoid is a set M equipped with a binary operation $.:M\times M\to
 M$ and a distinguished unit element $u\in M$ such that for all
   $x,y,z\in M$:
$$x\cdot(y\cdot z) = (x\cdot y)\cdot z$$ and
$$u\cdot x = x = x\cdot u$$
Equivalently, a monoid is a category with just one object. The arrows
  of the category are the elements of the monoid. In particular, the
  identity arrows is the unit element $u$

So, a monoid is a category with just one object. What it means exactly? $M$ has more than one object. Later the book cites $\mathbb{N}$ as being a monoid. Why?
 A: The monoid $M$ may have more than one element, but the elements of the monoid are not objects of the category in question.

The category in question is defined as the category whose sole object is $M$, and whose morphisms are the elements of $M$, where composition is defined as element-wise  multiplication in the monoid.

The key is to then verify that the axioms for a category are satisfied.
A: If $C$ is a category with a single object, then the morphisms of that category, that is, the morphisms from that single object into itself, from a monoid (the identity morphism is the unit element of that monoid).
And if $M$ is a monoid, you can create from it a category $C$ with a single object in which the morphisms of that category (which are, again, the morphisms from that single object to itself) are the elemnts of the monoid.
A: "$M$ has more than one object..."
In most cases a monoid has indeed more than one element, but the elements are not objects in this context, but are arrows/morphisms.
The composition of arrows is then the binary operation on them.
The unique object serves as domain as well as codomain for these arrows so that for every pair of arrows $f,g$ composition $f\circ g$ is defined (this in contrast with the situation in which there is more than one object).
Composition in categories is associative and the unit serves as identity.
You might wonder: "then what is that unique object?"
Actually that does not matter so much (categories can be defined without the use of the concept "object"), and you make your own choice. It is not common, but it won't hurt if for instance the identity arrow also gets the predicate "object". 
