They are both two stages of water filtration. They work on different principles and therefore have different potential and effectiveness.
Ultrafiltration basically operates at water pressure and works with a series of filters, generally active carbon filters, to remove pesticides, solvents, viruses, bacteria, suspended solids and other impurities between 0.01 and 0.1 microns from the water.
Reverse osmosis, due to the effect of a pump operating at different (higher) pressures than that of the aqueduct, always works with a series of active carbon filters to which, however, is added an osmotic membrane that allows the removal of fixed residue (salts, heavy metals, contaminants, ....) above 90% and removes all suspended elements smaller than 0.001 microns.
Today, reverse osmosis provides the best results for domestic water purification in a mechanical and natural way.