In some states, California for example, your intent to steal at the time you entered the store would be enough to arrest you for felony burglary, even if it was a cheap cup of Ramen noodles. Of course, proving your intent at the time you entered would be quite difficult, that is the way the statue reads.
If you took the items with the intent to steal them then you committed the offense... it does matter that you decided to put them back, although that can be seen as mitigating circumstances later.
I suspect you made statements during all of this that will be used against you. Attempts to explain things more often than not just make things worse. The best thing you can do in these circumstances is keep your yapper shut.