Would I be able to buy an iPhone 5s from a T-Mobile store and then activate the $30 prepaid plan?

Like can I buy the phone at the store and activate it or do I have to buy the phone at Walmart while I get the plan.

No. You would have to purchase one of the few available phones from Walmart and then activate that phone with the $30 airtime prepaid card from Walmart.