I was pretty nervous around girls in junior high and high school, so I can certainly sympathize with your situation. A very similar situation happened to me once (though I was just making conversation for practice in a situation that arose randomly, and had no expectation of or plan for dating that girl). And, based on that experience, I think that there are some issues with your overall view of the situation which make it harder for you.
1. If you're working towards a romantic relationship, you're working towards a romantic relationship.
It doesn't matter if you're trying to insert some arbitrary step, like "being friends first", because if it's nothing but a step along the way to what you really want it will be difficult to pretend that those steps are meaningful in themselves. From what was written in the question, it seems more like friendship with this girl is just a part of your effort to get her to date you-- that is to say, if you didn't want to go out with her, you might not really want to be friends with her at all. Pretending that the friendship and romantic relationship are totally separate goals when they are not isn't going to lead to anything good for you.
This is worth thinking about for you (consider if you're being honest with yourself and with her about what it is that you want, and why) and for her (it's plausible that she is picking up on what you really want, or that your stated goals don't match your behavior). At the same time, if you treat the situation more like a potential friendship you might find it easier to talk to her in general, and easier to form a relationship (romantic or otherwise) down the line.
2. Most social interactions like this are pretty low-stakes. This is true even if it's hard for you, personally, to initiate the interactions.
It took me a long time to learn this one, and I desperately wish I had learned it sooner. It's clear that you place a lot of importance on each individual interaction you've had with this girl-- you've kept a count, and review lots of perceived details about each, and treat each one as containing crucial information to use in your next interaction. If you feel that something has gone wrong, it's easy to treat it as a massive catastrophe in your mind.
That places a lot of pressure on you, her, and every time you interact. A 5-10 minute conversation in the school hallway simply isn't important enough to justify that. Consider your interactions with your friends-- do you enjoy them, and enjoy spending that time with those friends? Do you pore over every aspect of each interaction that you can remember? Do you need to focus and build up your courage to speak to them? You might (some people are socially anxious), but I'm betting that you don't.
Carrying that kind of tension tends to make people behave differently than they normally do, and can make others tense and anxious as well. If nothing else, treating every small interaction with her as a major event sends the wrong signals: that's not how friends interact with one another, it makes casual interactions seem less likely, and it adds a bit of hassle to interacting with you.
This recent event you describe sounds pretty minor. I doubt she'll be thinking about it much, if at all, a week or two after the fact. A casual manner, along with a comment like "ugh, my friends are really obnoxious. Sorry about that." along with an eye roll is about as strong a response as I would advise. Considering a big apology event is way too much.
3. Be honest with yourself and with her about what you want and why.
If you are laser-focused on dating this girl then it's understandable that you might view any given interaction with her in relation to that goal. But her side of the experience will then mainly be that some guy wants something from her. Conversely, if you enjoy spending time with her, and are happy to spend time with her whether or not it gets you any closer to a date, then there is more space for an actual relationship to develop.
Consider a few questions like "why do you want to chat with her between classes?" and "why would you give her chocolate?". An answer like "I want to date her" isn't very compelling and, as above, arbitrarily raises the stakes on any encounter. But if your answers are more like "we both like X, Y, and Z, and I want to talk about those" or "I have a chocolate bar but didn't want to eat the whole thing myself. Since she likes chocolate, she can have the rest" are much more natural, lower-stress explanations.
So, what should you do?
It's hard to give specific advice with so little information on the overall situation (a fundamental problem with not knowing either of you or observing how you interact). But my first specific piece of advice is to relax a bit. Things may or may not work out as you hope with this girl, but I guarantee that stressing out over it will not help.
If you can approach her just to talk about common interests, without making the conversation a major event in your mind, you should do so. This means that minor embarrassments, like your friends' comment, aren't deserving of much of your attention. It also means that, even if the conversation is brief or lackluster (in your mind), that is not a failure. Sometimes conversations fizzle, even between close friends. If she's rushed and not able to talk at all one day, that's completely fine. The more you make talking to her at all a big deal in your mind, the harder it will be to actually do it.
My second piece of specific advice is to not give her the chocolate. Giving gifts carries some implications, especially if it's planned (as this would be). And chocolate in particular is often associated with being a romantic gift. From what you've described here, it doesn't seem to me that your relationship with this girl is one that accommodates anything more than an incidental gift (oh, I didn't realize this was a dark chocolate bar! I don't really like that, do you want it?). If you may be giving a somewhat wrong impression so far (which seems likely), giving a present might exacerbate that wrong impression rather than fix it.
My similar situation: I'm adding this in response to a request in a comment. I don't know how directly relevant it will be to the OP's situation, but with the details listed readers can assess that for themselves.
When I was in high school I was on the track team, and one of my events involved a lot of waiting in line for your turn. At one track meet, a girl on the track team (widely considered to be one of the most attractive in the school) with whom I'd had some brief, minor conversations, happened to be right in front of me in line. Because we were casually acquainted we were chatting (I've no recollection of the topics, it was very small talk), and a couple of guys on the team in other events passed by and yelled out "yeah, Upper_Case!" or something like that. The obvious implication was "way to go, talking with the hot, popular girl".
It was embarrassing, as it carried the suggestion that this nothing conversation was some big deal for me. But it wasn't a big deal, since it was a low-key conversation, so aside from rolling my eyes I ignored the comment. She almost certainly understood what the comment meant, but also ignored it because it was not important and also not something about me or anything I had done. The only way it would have been a big deal would have been if I had fixated on it.
Instead, the conversation continued without incident and our friendly acquaintanceship went on into the future as well.
More broadly, when I liked a girl I would typically overthink every minor interaction and try to game out what things "meant", whether they were trivial or not. It often took me days to work up the nerve to talk to someone I had a crush on. This made it very hard to actually start conversations, set odd goals for those conversations (what is there to get out of a discussion of what someone did over the weekend?), made conversations much more stilted and less natural, and ultimately made developing any sort of relationship more difficult.
It took a great deal of effort, but when I shifted my focus away from "how does [event X] impact my chances for getting a date" and towards more casual, non-goal-oriented interactions, I experienced a lot less stress. I also had a better time socially, and had more and better dates.