Ecclesiastes 6:2 (NASB)
a man [H376] to whom God has given riches and wealth and honor so that his soul lacks nothing of all that he desires; yet God has not empowered him to eat from them, for a foreigner [H376] enjoys them. This is vanity and a severe affliction.
The Hebrew words for the two men ('man' and 'foreigner') are actually the same word.
a man
אִ֣ישׁ (’îš)
Noun - masculine singular
Strong's 376: A man as an individual, a male person
The context, of course, reveals that they are two different individuals.
Strong's Exhaustive Concordance
a man as an individual or a male person; often used as an adjunct to a more definite term -- also, another, any (man), a certain,
The second man is opened to interpretations.
At https://biblehub.com/ecclesiastes/6-2.htm, 5 versions use 'foreigner' and 18 versions use 'stranger'.
Who is the “foreigner” in verse 2, and why is he the one enjoying the riches/wealth/honor God gave to someone else?
The Hebrew original does not specify “foreigner”, but just another man. The point that Ecclesiastes is trying to make is the randomness of it. One man receives riches; another man enjoys them.
This is meaningless, a grievous evil but it happens.