While it's true that businesses can assert First Amendment rights, as with this recent Supreme Court case https://www.nytimes.com/2017/03/29/business/supreme-court-cr..., that doesn't mean that laws that make it illegal to inquire about or take into account past salary history, marital status, pregnancy status, etc. are all unconstitutional simply because spoken communication might take place during the process of flouting the law.
Or to put it another way, it's not the words, "So, are you pregnant?" themselves that are the problem. The problem is the implicit idea that an interviewee's answer to this question will affect the employer's hiring decision, and the law says it should not.
This is fitting into the same category of not being able to ask candidates; what's your sexual preference? what's your religion? do you smoke? are you planning on having children? etc. as part of the hiring process. They are rules that help avoid discriminatory hiring practices. At the end of the day they help companies more than the individual. The individuals are already protected from discrimination and could sue if these questions came up during an interview and they didn't get the job. Banning these questions ensures companies and their interviewers avoid situations where they could become legally liable.
Whether salary info helps the company or individual more is debatable since this does not represent a protected class, but obviously the goal is to support the individual.