What we may have overlooked, however, is that this second reference of Peter's ('to those who are afar off'), is not taken from the prophecy in Joel, and may not be a reference to the Gentiles receiving the gift of the Holy Spirit.
Let's have a look at the passage:
28 And it shall come to pass afterward, that I will pour out My spirit upon all flesh; and your sons and your daughters shall prophesy, your old men shall dream dreams, your young men shall see visions:
29 And also upon the servants and upon the handmaids in those days will I pour out My spirit.
I've emphasised the word 'your', because Yahweh is directly addressing the Jews. We must note also that the entire context of Joel 2 and 3 is what Yahweh intends to do for the Jews. This is an extremely important point, because it is critical to our understanding of both the primary and the secondary fulfilments of the prohecy.
From this passage alone, it would appear that only Jews are to be the recipients of this outpouring - at the very least, it is not necessary for Gentiles to receive the outpouring in order to fulfil the prophecy, for no Gentiles are mentioned at all.
But what does Peter say? When he quotes Joel, he does so directly:
17 And it shall come to pass in the last days, said God, I will pour out of my Spirit on all flesh: and your sons and your daughters shall prophesy, and your young men shall see visions, and your old men shall dream dreams:
18 And on My servants and on My handmaidens I will pour out in those days of My Spirit; and they shall prophesy:
The recipients, we note, are the Jews, as we saw in Joel 2. But later in the chapter, Peter adds this:
38 Then Peter said to them, Repent, and be baptized every one of you in the name of Jesus Christ for the remission of sins, and you shall receive the gift of the Holy Ghost.
39 For the promise is to you, and to your children, and to all that are afar off, even as many as the LORD our God shall call.
We note that Peter uses the same language we found in Joel 'you' and 'your', but that he adds also 'and to all that are afar off''. This would appear to be speaking of the Gentiles, but Joel 2 does not mention the Gentiles at all. Is Peter telling us something which Joel omitted? Is Peter adding these words because they are speaking of a situation which is different to that described in Joel 2?
The answer is that in Acts 2:38-9, Peter is not referring to Joel 2 at all. He doesn't even quote it. In fact, it's fascinating to note that as far as Peter is concerned, this is the fulfilment of Joel 2 right here:
14 But Peter, standing up with the eleven, lifted up his voice, and said to them, You men of Judaea, and all you that dwell at Jerusalem, be this known to you, and listen to my words:
15 For these are not drunken, as you suppose, seeing it is but the third hour of the day.
16 But this is that which was spoken by the prophet Joel;
I've highlighted the word 'these', because this is the group whom Peter identifies as fulfiling the prophecy of Joel 2 (at least in part). They are all the Jewish disciples of Christ.
Each and every one of them. When Peter quotes Joel 2 therefore, he does not step out of the context in the least, and he does apply the words of Joel 2 to the Jews and to the Jews only (as does Joel 2).