God created the heavens and the earth and man in six days. Plants, grass and trees were created before man. I think your confusion is that you have taken verse 5 out of the context as it is written in chapter 2.
This is how it reads - Genesis 2: 1-6 Thus the heavens and the earth, and all the host of them, were finished. And on the seventh day God ended His work which He had done, and He rested on the seventh day from all His work which He had done. Then God blessed the seventh day and sanctified it, because in it He rested from all His work which God had created and made. This is the history of the heavens and the earth when they were created, in the day that the Lord God made the earth and the heavens, before any plant of the field was in the earth and before any herb of the field had grown. For the Lord God had not caused it to rain on the earth and there was no man to till the ground; but a mist went up from the earth and watered the whole face of the ground. This is a New King James version of the Bible.
To help make it simple - God had finished creating an environment for man to live in - air for man to breath, day and night for activity and rest, water to drink, plants, trees, herbs, for food, animals to be cared for and companionship for man, (they weren't originally created for food that came after the flood) and when our habitat was created then God created man on the sixth day. God finished His creation with the seventh day a day of celebration and rest from His creation and He sanctified the seventh day. I believe the point of verses 4-6 isn't that God had not created the plants yet but that there were not a lot of men to till the ground and that it had not rained on the earth yet but the plants were watered from a mist that came up from the ground. We only had Adam and Eve at that time and God had placed them in the garden of Eden and Adam had not yet been banished from the garden to till the ground. That came a little later after sin entered the world with Eve touching and eating the fruit from the tree of Knowledged of Good and Evil. Rain did not come until the flood. It's hard for us to understand no rain just a mist coming up from the ground to water things because we know about rain. But people before Noah's time only knew of the mist that came up from the ground to water the plants and trees. It is part of the reason people gave Noah such a hard time about building a boat away from water..
I hope I have helped you understand this a little better.
To help simplify