All perfect praise be to Allah, the Lord of the worlds. I testify that there is none worthy of worship except Allah and that Muhammad is His slave and Messenger.
If you doubt whether or not this substance was on your skin before performing Ghusl, then it should be attributed to the most recent time it was likely there. Accordingly, you assume that it occurred after having performed Ghusl (which is more recent than before Ghusl), and thus your Ghusl is valid.
If you are certain that it existed before you performed Ghusl, then if it is an insignificant amount, the Ghusl is valid according to the view of Shaykh Ibn Taymiyyah . If it is much, then it is an obligation on you to remove it and wash that place only because continuity is not a condition for the validity of Ghusl (i.e. you do not have to wash all the parts immediately after each other). You have to make up for the prayers that you prayed during that period because they lacked one of the conditions for the validity of the prayer, which is purity.
However, if you are affected with Waswaas (obsessive whisperings), then you should neglect these doubts and not pay any attention to them at all because being carried away with them leads to a great evil.
Allah knows best.