It looks like you have a combination of independence and defiance, just as would be expected! What we all need to remember as parents is just because something is EXPECTED doesn't mean is has to be ACCEPTED. For example it is perfectly expectable that a 2 year old may bite you or another child, but that doesn't mean it is acceptable. There would be consequences. What we all need to decide is what will be acceptable in our families.
As for the sneaking things to school, it seems there may be some miscommunication with your daughter and a chance that she really didn't know she couldn't bring those things. For this I'd just sit down and clearly set out the expectations for non-school items in the backpack. Pencils, paper, homework, etc. are great, but anything else she needs to ask about. If she sneaks again there will be consequences. Then follow through with those. Like you said it is not about the items, but the sneaking.
As for the continuing to do something after she's been told to stop, that is not childish. It is disobedient, and needs to stop. Two year olds are old enough to know that NO means No. It will be a long hard road for her in life if she doesn't learn this important lesson. There should be imediate and unpleasant consequences for not obeying the first time. No counting to three, or 'if I have to tell you one more time...', just go straight to 'I asked you to stop (don't, clean-up, whatever) and you didn't so now ...(whatever the consequence is). The consequence for each type of disobedience should be the same each time. For not turning off the tv when asked, no tv for a week. For not cleaning up when asked, the toys, crayons, playdoh, whatever is gone for a week. For not getting ready for bed when asked, bed time is 1/2 hour earlier for a week. For not doing a job (set the table, make the bed, etc.) when asked, another two jobs are added. You get the idea. :o) She will too! We also have a consequence for complaints about the consequences. She decided to disobey and she knew there would be a consequence. She made her choice, so there will be no complaining/whining about it. I usually make the original consequence worse (another two days without for each complaint, or similar). My girls learned really quick that things only got worse when they started complaining. They also learned really quick that life is better when they just do what is asked of them when it is asked.
You are correct that rules and boundries are needed. Kids are like rivers. When the stay within their boundries, they are amazing, powerful and terrific assests to the world, but when they start spilling over the edges they become destructive to themselves and everything around them, not mention a giant mess!