Does the force of friction and other contact forces arise due to gravitational attraction ? If not, what is the origin of these forces?

No, the contact forces have electrical origin.