By what title should I greet assistant and associate professors in emails and letters?
Assistant and Associate Professors in the US can be formally addressed by "Professor" or "Doctor/Dr.". There should be no offense given with either salutation, and either is appropriate.
It's interesting actually,
As an Australian undergrad I've never referred to any of my lecturers or tutors as anything but their first names, and would find an insistence on titles in such a situation to be... well, frankly an exercise in serious anal retention.
However while applying for postgraduate studies, all of my 'reach out' emails trying to attract supervisory interest use the appropriate titles. While almost all of the replies come back establishing a first-name basis for future correspondence, I wouldn't dream of initiating said correspondence informally.
Highlights cultural differences across countries too - I'm fairly certain that if a senior academic at my uni in my field started insisting that his or her students use their full titles, the rest of the department would give them a far less flattering unofficial one.
It's quite important to consider what your position is in this relationship, and you don't specify. In almost any situation, it is probably best to address your first email using the "Dr." or "Prof." title, to be polite, and to continue to do so until it seems that the tone of the responses are less formal. Of course, that is a subjective thing to judge. But I can't give you much advice about that!
You will have to read from the tone of the responses at what point (possibly after only one email) the Prof. is OK with a less formal form of address. If you are an undergrad student in their class, it might not hurt to stay with the more formal title, even if you are of a similar age to them.
I was trained in the UK and now work in the US system, and I feel like there is a lot of similarity. Basically, it's fairly informal, within limits. As an assistant professor myself, I do prefer undergrads to address me as "Dr." or "Prof." (as a US class instructor, not the same as the UK Professor) in more formal correspondence, and I think that's usual in the US and UK. Graduate students and above can normally expect to be safe to be on first name terms provided their emails remain fairly professional and carefully written, i.e. they don't rapidly degenerate into txtspeak or very casual, potentially rude, references or phrasing.
So, if you are a graduate student or post-doc, and you are at the same department, or even institution, I encourage you to consider using their first name once that initial correspondence has been exchanged and if they sign with their first name. It's never "wrong" to continue to use a more formal term of address, but it can sometimes become awkwardly too formal for relaxed academics.
Now, take into account the personality of your correspondent. If he or she is very senior in age or accomplishment, or maybe has given an impression of great self-importance (i.e., ego!) then you may be better off staying slightly more formal in case you are perceived to be disrespecting them before you know them more personally. Honestly, though, I think that is an increasingly rare (but not unheard of) phenomenon.