You're not just facing minor drug charges. Police are saying you intended to distribute the drugs. That could lead to a strict sentence.
What you're wondering, then, is how they determined that you intended to sell the drugs. That's not what you told them; you may never have thought about it in your life. There are six different ways that police may arrive at the conclusion.
1. They saw the drug deal happen. For example, you may have sold to an undercover agent, so they know you intended to sell the rest of what you had.
2. The drugs were in packages. You didn't just pull them out of your pocket; you had multiple plastic bags, all with the exact same amount sorted into them.
3. You had more than would reasonably be purchased for personal use.
4. The police also found a large amount of cash. They determined that you got this money by selling drugs in the past and that you're planning to do it again.
5. They found other paraphernalia that is often used to sell drugs. This could include a scale for weighing out amounts, for example.
6. The police found messages from people who had already bought from you. For instance, perhaps they searched your phone and found text messages in which you told people where to meet up.
Of course, a lot of this is circumstantial. It's not illegal to own cooking scales or have cash at your house. It's crucial that you know all of the legal options you have when facing these serious charges.
Source: FindLaw, "Legally Speaking, What is Intent to Distribute?," Andrew Chow, accessed Aug. 31, 2017