Is the chord creating the melody or finding the chord according to the melody

In my case, considering I often hunt for guitar riffs with this workflow, I find a series of chords first

Even because I don’t know music theory, so finding chords according to the melody could be very tough, if not impossible