If I buy a used iPhone from someone can I use it without a contract?

If I buy an AT&T iPhone from someone that had it with a contract, does that mean I have to get a contract too or can I get a month by month plan from AT&T?

It depends. If the phone is unlocked, then you can use it without a contract on any service. If you want to stick with ATT, you can put a ATT go-phone sim card in (which is a contract free service) and it won't matter if the phone is still locked.