Why does my book consider moment of inertia as a scalar when it is a tensor?

It can be treated as a scalar when the body is constrained to move on a single rigid axis. In this case you have a line of points through the body that are fixed to not move. All other points move around this axis. Due to the body being rigid every point will exhibit circular motion around this axis with the same infinitesimal angular displacement. The body's rotation motion is now 1-dimensional. This is how most lower level undergraduate or high school books would introduce the topic since tensors and matrices might be beyond the level of the student. This makes learning the basic concepts a bit easier. In upper level courses and texts the tensor treatment is standard, the constrained case being a special case.

The moment of inertia is a scalar when calculated as seen here, which is the same as stated in your book.

Moment of inertia is the name given to rotational inertia, the rotational analog of mass for linear motion. It appears in the relationships for the dynamics of rotational motion. The moment of inertia must be specified with respect to a chosen axis of rotation. For a point mass, the moment of inertia is just the mass times the square of perpendicular distance to the rotation axis, $$I = mr^2$$

When all the possible axes of rotation are taken into account, a tensor can be defined.

Inertia tensor

For the same object, different axes of rotation will have different moments of inertia about those axes. In general, the moments of inertia are not equal unless the object is symmetric about all axes. The moment of inertia tensor is a convenient way to summarize all moments of inertia of an object with one quantity. It may be calculated with respect to any point in space, although for practical purposes the center of mass is most commonly used.

Actually in general case it is a tensor. But may be they assume that there is some spherical symmetry in the task? Every moment of inertia tensor, as a symmetric tensor, may be brought to diagonal form, in case, when all eigenvalues are equal, the problem is sprherically symmetric, and in that case they may treat at as a scalar.