Short answer
HubSpot's KB: set formatting on a property's Rules tab, for custom text properties and some default properties. Automatic formatting is not enforced on data entered through the mobile app, forms or workflows.
1. In HubSpot
The relevant screen in my demo portal.

2. Worth knowing
Clean existing data separately, since rules apply to values as they're edited in the CRM.
3. Related
Phone number validation and phone formats and duplicates.