I admire your desire to learn to play in the absence of lessons and commend you on your resourcefulness in teaching yourself to play some basic melodies by listening to songs on the internet.
To advance, it would be helpful to learn at least some basics of music theory and chord theory. It is beyond the scope of the way this site works to provide everything you need to know about chord theory to get you from where you are now to knowing how to apply basic theory to determine what chords to play with the notes.
But I will try to give you some brief ideas that you can use while you are learning more theory.
When you play a song on piano, you would typically play the melody with your right hand and either a bass line or harmony (chords) with your left hand. The chords you play with your left hand will usually be derived from the melody notes you are playing with your right hand.
Generally, a chord played over a melody line in a measure of music, will contain some or all of the notes in the melody line that is being played at the same time as the chord.
Once you understand a little about chord theory and chord progressions, you will be able to narrow down the chords that could possibly be used in any given key that your song is in. From there you can often determine the chord from the bass note of the chord, which usually is the root note of the chord. So if the bass note (lowest frequency) of a chord you are hearing is a G - then it is likely that the chord is a G. Of course if the chord being played is an inversion (notes of the chord played in a different order not starting on the root), the root note will not be the lowest note.
Also, if the song you are trying to learn to play has a bass line (often played by a bass guitar), most often the bass line will contain the root note of the chord that is being played and the bass line will often start on the root note of the chord for a given measure. When trying to find the chord through trial and error, the bass line will often give you a strong clue of where to start.
One thing you should understand about chords in general, is that in most cases (with a few rare exceptions) the notes available to form the chords in any given key, will be derived from (found in) the notes of the scale corresponding to that key.
For example - if you learned to play a melody on piano by listening to the song and it turns out that all of the notes in the melody are played on the white keys and none are on any black keys, there is a good chance the song is in the key of C major.
All of the white keys play notes in the key of C major. If your song is in the key of C major the notes available to form your chords are all played on the white keys.
There is a certain set of chords that will go with any given key. Until you learn more about chord theory, you can use the chart below as a guide to narrow down the possible chords that might be used in your song. There are other chords that could be used (seventh chords, diminished chords, augmented chords, ninth chords, suspended chords and others). But this chart shows you the most common chords associated with each key.

Once you figure out which key your song is in - you will be able to narrow down the possible chords used in the song by using this chart. Then by using your ears, you should be able to determine which of those possible chords you might be hearing at any given point. But also, take a look at the melody notes that are played or sung while the chord is playing - and in most cases the chord will contain several of those notes. It may also be helpful to note that for most songs (but not always) the first chord played will be the Tonic/Root chord (the "one" chord that corresponds to the key of the song).
To learn more about how melody notes relate to chords, click here How melody notes relate to chords
In summary - finding the correct chords for a song by listening, will often be a trial and error process - meaning you try different chords until you find the one that sounds right. Hopefully the concepts and ideas presented above, will help you shorten the trial and minimize the error.
You have a long and rewarding journey ahead as you strive to continually improve your skills on piano. Enjoy it as much as you can!