The verb "have sunbathed" is in the present perfect tense. The present perfect is used to speak about something that happened at an undisclosed time in the past and which has a relationship with the present. The verb "was" is in the past tense.
The phrase "When I was in..." implies that you are about to tell us something that happened in the past, so you must use some variant of the past tense (e.g. past, past continuous, etc) to do so. This is not to say that the present perfect and past tenses can never be used together; they can, e.g. I was in Sharm El-Sheikh last week, I have vacationed there a lot.
Sunbathing means to sit or lie in the sun. It does not mean "to make the skin brown or darker", although that is often a consequence of sunbathing, and frequently an intended consequence. The correct term for "making the skin brown" is tanning. People will sometimes say they are sunbathing when they are actually lying in the shade, enjoying the warmth. In this case the likelihood of tanning is reduced.
People can sunbathe for many reasons other than to get a tan, e.g.:
- they may have a medical condition that is improved by exposure to UV radiation, such as psoriasis or vitamin D deficiency,
- sunbathing releases endorphins that make them feel good,
- they are relaxing for a period in between swimming at the beach or pool.