Do you just pour water/lava around in a hole randomly? I tried that but it still didn't work.
There is no way to make infinite lava sources in the current version vanilla Minecraft.
Infinite water sources are created when 2 or more water source blocks (the ones you place/pick up with buckets) are both flowing directly into another block, like this:
The block that was previously air becomes another water source block. This means that you can pick it up with a bucket, and then the 2 other water sources will create it again.
Note that if you take either of the 2 original water source blocks, they will not reform. This is because they only have 1 other water source flowing into them.
You can create an infinite water source in which you can take any of the water sources like this:
Whichever block you take, there are 2 still existing sources to the side of it which will recreate it.
Also note that for water sources to form there needs to be block directly under where you want the water source to form. This example will not work because there is no block underneath where the 2 water sources are flowing into: