So what you need to understand is how to make use of thematic transformation techniques which is nothing more than thematic development. Here's how it works:
You probably know that any musical theme has the 3 main elements: melody, rhythm, and harmony. In one theme melody would be more pronounced, in another rhythm and so on. Therefore, we can label certain themes as melodic themes or rhythmical themes or harmonic themes.
So when you want to develop your theme over the course of the piece, you can change any of the 3 elements:
1) For melody of the theme, you can change intervals (smaller or larger), you can change the direction of the intervals (inversion), you can play the theme backwards (retrograde), or you can even use retrograde-inversion when the theme is played backwards with inverted intervals.
2) For rhythm of theme, you can change rhythmical figures and meters, make the rhythmical values smaller (diminution) or larger (augmentation).
3) For harmony of the theme, you can change modes and chords.
By transforming melody, rhythm, and harmony of the theme, you can create a piece in various forms, including but not limited to variations, rondo, sonata, rondo-sonata, fantasia etc.
Franz Liszt was very good at using thematic transformation so you can look at many of his works, including his Fantasia and Fugue on "Ad nos at salutarem undam" for models. Also Beethoven was able to weave the entire symphony No. 5 out of the famous opening 4 notes.
Because we always look at the work of the masters from the past for inspiration, studying how they developed and transformed their themes will be a great education for you.
By the way, do you want to learn my special powerful techniques which help me to master any piece of organ music up to 10 times faster? If so, download my video Organ Practice Guide.