Your folders are not "stored" on your iPhone, they're stored on the server. But if you navigate to a folder then the server will push however many messages you've specified in settings (i.e. "Show xx Recent Messages"). If you don't want to populate your iPhone with the contents of these folders, don't open them. If you've already done that, delete and re-add the account to your iPhone.
If I misunderstood and what you really mean is that you don't want these folders accessible on the iPhone, you can't set up the account such that it doesn't give you access to all the folders. You could however set up a 2nd account where your primary account forwards its Inbox to a secondary (separate) Yahoo account on your iPhone. That way only your Inbox is on your iPhone.