You can mix coffee grounds directly into soil.
Adding and mixing coffee grounds into the soil helps improve the drainage of the soil, the structure of the soil, and aeration of the soil.
The coffee grounds also add nitrogen and micronutrients to the soil, but should be mixed into the soil or added in with compost and not just applied to the soil in thick layers.
Just applying the coffee grounds to the soil in thick layers, can repel water and harm plants, and so the coffee grounds work best for the soil when used as soil amendment or in compost, by adding green material and nutrients for soil organisms like works.
To use the coffee grounds as a soil amendment, mix a thin layer of around 1/2 inch deep of coffee grounds into the top few inches of soil before planting in the soil.
As a mulch you can carefully sprinkle the coffee grounds thinly around plants, but cover the coffee grounds with other mulch, like leaves or bark, to prevent a crust from forming which blocks water.
And keep the coffee grounds a bit away from the plant stems.
In compost you can add the coffee grounds as a green nitrogen rich component, which balances with browns like leaves and about 3 parts leaves to 1 part grounds by volume.
As a soil drench, coffee grounds can be used as a liquid solution mixed with water to deter slugs as well.
Just be sure to not put too much coffee grounds near your plants as they can harm the plants.
And certain plants don't do well with coffee grounds, while other plants thrive on coffee grounds.
So be sure your plants can handle the coffee grounds before adding or using the used coffee grounds around them.