As written, both sentences could be used to state that one does not want to go to a particular concert and would like to stay at home instead. The first is mildly unusual for American English conversation, but not overly much - nobody would comment on it and everyone would understand what you meant. The second is more often used (in my experience). With a small modification to the first statement a significant difference can be seen.
Suppose we change the first version to the following:
I prefer staying home to going to concerts.
Here we're saying that as a general rule we do not like attending concerts and would prefer to stay at home. It doesn't matter which concert, we don't want to go. In my experience this construction, using gerunds instead of infinitives, is used primarily for generalities.
The second statement is more natural sounding, though it is a bit more formal than what I normally hear in conversation.
I'd prefer to stay home (rather) than (to) go to the concert.
This refers to a specific concert that I do not wish to attend. If I changed it to a concert instead of the concert then this would have the same generality as the first version, and it would still be idiomatically correct. The parenthetical "to" is usually omitted with simple statement where the comparison you're making is obvious. In a more complicated sentence (perhaps using longer technical words or a particularly long phrase as the first item being compared) it would probably be included.
For American English conversation, the following is how this sentiment would likely be stated.
I'd rather stay at home than go to the concert.
There is a subtle difference, but it's not due to something being a single event or not.
I prefer to have a cup of coffee (this time).
This isn't talking about a particular event because of to have, it's a particular event because of the use of a in the sentence construction.
Contrast it with the following:
I prefer to have single cups of coffee (in general).
Now, it's no longer a single event. It's talking about an ongoing state of affairs and intentions.
So, let's compare those two sentences:
I prefer having single cups of coffee.
I prefer to have single cups of coffee.
The only real difference between the two, which is often not really thought about, is that the former talks more about those times during which a single cup of coffee is in the process of being had. Meanwhile, the latter talks more about the nature of how the coffee will be had.
It's a subtle distinction. In fact, most people would probably frame the statement differently, bypassing the distinction altogether:
I prefer single cups of coffee.
A similar analysis could be performed on your first sentence, although I need to rephrase it slightly:
I prefer swimming to running.
I would rather swim than run.
I would say that the distinction here is even more subtle and less present. But if it's to be made at all, it would again be that the first sentence talks more about being currently engaged in the process of the activity (perhaps in the context of enjoying it), while the second talks more about the idea of the activities (perhaps theorizing about their benefits).
In both cases, however, there is really no effective difference between the two. They are often used interchangeably.
Best Answer
Learners of English have been constantly asking this type of questions that revolves around two important titles of English Grammar - Gerund and Infinitive. In this answer I am not going to explain what is Gerund and what is Infinitive (you can easily find a lot of references regarding these tow titles in Google or in any text books). Rather, I will focus on other aspects related to Gerund and Infinitive.
In English there are certain verbs that takes only gerund (like enjoy), some verbs that take only infinitive (like want), and some verbs that take both. So you have to learn which verb takes what form of verb.
But for a learner, the trouble doesn't end there. Now a new problem arises and it is related to those verbs that take both gerund and infinitive. Why? Consider the following examples (In these examples the verbs can take both gerund and infinitive) -
In those examples both stop and start take both form of the verb. While sentence #7 and sentence #8 are similar in meaning, sentence #5 and sentence #6 aren't. Sentence #5 says He stopped in order to have his lunch, while sentence #6 says He stopped while taking his lunch. So the problem for the learners with those verbs that take both gerund and infinitive is to again study and learn which form convey what meaning and when the two form convey similar meaning.
For that there is no set rules that I am aware of, you have to study a lot and observe. If anyone know any rules regarding this please let us all know. Thank you.
And @nima, as for your question - "As a native speaker, which one and when or where would your rather write or say?" - what I can say is that when the verb can take both gerund and infinitive, and when they both mean the same, the choice is up to the speaker; it's completely speaker's preference, mainly governed by regional influence, or personal choices. That's all I can say :)