I think my confusion stems from this: if a book is resting on a table
I understand that the force of gravity acts on the book and as it is
in equilibrium, the table exerts a force equal in magnitude on the
book so that there is no net force.
That is correct. The relevant pair of forces are circled in blue in the figure below.
Is it correct to say there is an electrostatic force that the book
applies on the table equal to its weight that the table then exerts
back, but why would it be equal to its weight?
The contact forces between the table and book are circled in red in the figure below. The force the table exerts on the book is equal and opposite to the force the book exerts on the table, per Newton's 3rd law. What keeps the force of gravity from pushing the book through the table are the repulsive electrostatic forces between the molecules of the table and book. The mechanical analog is to imagine the molecules interconnected with one another by springs that get compressed due to force the book exerts on the table and the table exerts on the book. Overall the compression of the springs (deformation of the book and table) is so small as not to be visible to the eye.
So now, if a car is accelerating so has a force acting on it, if it
were to collide with a wall a force would be exerted on the wall and
on the car, but where does it come from - is it the same as the book
on the table?
The force on the car comes from the rate of change in its momentum brought about by the wall bringing it to a stop. The net force on an car equals its rate of change in momentum, or
$$\vec F_{net}=\frac{d\vec p}{dt}=m\frac{d\vec v}{dt}$$
The force exerted on the wall by the car is equal and opposite to the force the wall exerts on the car, per Newton's 3rd law. The nature of the forces is different from the interaction between the book and table as energy is dissipated in permanently deforming the materials of the car and/or wall in the form of heat and sound.
Hope this helps.