Do you need to tell them you are leaving or do you work at a desk job that is more lose on when you leave for breaks and other things?
If you have the freedom to get up and go without notifying people, I just walk out and do what I need to do.
Another thing that most of my office based jobs do is make use of headphones, even if you don't want to listen to anything. Some days I am in a grumpy mood and don't want people walking up to me to talk. Maybe this is just an IT thing, but it is understood by my experience in office etiquette that if someone has headphones on, they are trying to "focus" and not entertaining idle chat. Some times I wear my headphones even if no sound is coming out just so I can have that alone time (I have a fairly chatty department).
I suggest the headphones because that has also allowed me to pass on unwanted lunch socials by appearing to be working through my lunch. This though can technically still be perceived as a lie by some even if not vocally.
The other thing I noticed is your choice of words you use. In the first example, you provide them to make the choice to still be around you.
Instead of saying
"Oh no thanks, I am staying inside."
that can be interpreted as:
We can still hang out if you want but I don't want to go out.
Instead you can say something like:
You guys go on ahead, today I feel/want/need like eating by myself and just listening to music.
This isn't explaining yourself while you are explicitly expressing your desire to be alone this time. They can't really say they will still join you because you have already said that you want to be alone. Generally, people have enough respect to not really push further than that. If you still want to join them other lunches, you can add a "maybe next time I will join". That way they don't feel bad and think you are mad at them.
Your second example also allows them to still force their way to be with you with your word choice:
Oh you don't need to, I can go alone
To some people, that's still an invitation to tag along because you are still giving them the choice and they could easily reply:
"no, I don't need to come, but I want to"
Instead, again if you have to inform of your departure, you should try using more explicit wording that does not give the other party an alternative option:
No thanks, I am going to go on my own
Here you kindly decline and state you are going alone and not providing them an option to miss read your words. If you wish to meet up afterwords, you can always add in "but I will catch up with you guys in 20 minutes when I am back". Again adding something like that at the end can help ease the co-workers from thinking you all of a sudden hate them.
Of course, they may ask why as to them, this is a change in boundaries that they are not used to. I always find it best to provide minimal reasons why helping to put the other person at ease. You don't need to answer any whys after you stated your intentions. Many people here in IPS are also very firm believers in not having to explain yourself or provide reasonings. I don't see it so black and white because some situations (especially with family or people you will be spending a large part of your day around) you want to let them know you don't hate them or are suddenly mad at them, you just need your personal time too.
I may follow up declining their choice to come with:
"I enjoy spending my lunch break with you guys, but there are days I
just want to be left to my thoughts and music and I hope you guys can
respect that."
It's short, to the point, and establishes a boundary to the people involved that this will be a recurring event and they should not read into it as anything other than you want personal time.
But again, you don't need to provide a why, just make sure that your replies don't provide them a foot in the door to still choose to come as explained above :)