It is all well and good to have objective goals, such as running under four hours, or beating the competition or finishing your first marathon. These goals and targets help you do your best. So set appropriate objective goals and challenge yourself to achieve them. But keep these goals in perspective. They don't mean a thing after the race is over. All that matters then is whether you can look back on the race and say to yourself, "I did the very best I could have done today. I have no regrets."
Ironically, this superficially selfish attitude makes it easier for you to be a good teammate and to demonstrate good sportsmanship. Your ultimate goal is to do the best you can do, so it shouldn't ruin your day if your teammate or competition beat you. In the end, that's utterly irrelevant. All that matters is whether you did your best. So, you can cheer wholeheartedly for everyone else and celebrate their success, because their success doesn't subtract one iota from yours, nor would their failure mitigate your failure.