Ok, first of all "this is NOT a car" you can't just change gear like you do in most other forms of transport, with bikes you need to be aware that they need to be moving, if only slightly, to get them into gear, what you do is, pull the clutch in move the bike forward or backward as you pull in the clutch and select a gear, this will mean that if your in the "wrong" gear when you stop you will have to faff about trying to find the right gear from a standstill, not always easy and can make you look a total prat , but that's how it works. So even if you have to slam your anchors on try to remember to change down as well, not always easy but doable if you have enough practice, as your new to the biking world you only get to know about how your bike works by reading the manual and asking questions, you can't ask daft questions cos it's all new to you. try to be more aware of your surroundings and read the road in front of you, this way you can anticipate the traffic and avoid this problem. Don't worry and get freaked out by this, it all comes together with practice. Stay safe.
If you find yourself in say 3rd gear and stuck just rock the bike backwards and forwards as you press the gear change down with the clutch pulled in and let the clutch just bite as you select each gear, then as it bites pull the lever back again to go down another gear. Find a place that's safe and do it on purpose that way when it happens "for real" you will be ready and won't look a dick.