Under federal law, an employer may impose direct deposit as a condition of employment.
The Electronic Funds Transfer Act at 15 USC 1693k only says that employers may not require an employee to have a bank account at a particular bank:
No person may—
(1) condition the extension of credit to a consumer on such consumer’s repayment by means of preauthorized electronic fund transfers; or
(2) require a consumer to establish an account for receipt of electronic fund transfers with a particular financial institution as a condition of employment or receipt of a government benefit.
If the employee is allowed to choose their bank, then such a condition is legal under this law. The government's interpretation of this law is clarified in 12 CFR 1005 Supplement I at 10(e)(2):
- Payroll. An employer (including a financial institution) may not require its employees to receive their salary by direct deposit to any particular institution. An employer may require direct deposit of salary by electronic means if employees are allowed to choose the institution that will receive the direct deposit. Alternatively, an employer may give employees the choice of having their salary deposited at a particular institution (designated by the employer) or receiving their salary by another means, such as by check or cash.
That said, individual states can create their own legislation, and many have made it illegal under state law for an employer to require direct deposit. You didn't name a particular state so I can't be more specific, but there is a chart here created by a payroll company showing the legality of such policies by state.
Note that in some sense, the employee is not really being "compelled" or "mandated" to have a bank account - if the employer insists on using direct deposit, the employee is free to go look for a different job. US law does tend to recognize that there is a major power imbalance in employer-employee relationships, so there are many regulations; but at its root, it's treated as a contract between two independent parties who may each set whatever conditions they want, and enter into the contract only if they can agree.
In contexts other than employment, I would expect even fewer restrictions on how a bank account could be set as a condition for something. For instance, it could be a condition for using a particular product or service. Again, if you don't want to open a bank account, you are free to not use that product or service.