What "someone" told you is correct. Basically, you are giving unwanted visitors like slugs, snails, and rodents a free lunch with no benefit to your plants. The only benefit to the plants, in the long term, would be if earthworms are burying the material you put on the surface and it eventually decays (with a timescale of years, not days or weeks).
To make compost in the traditional way, you need a mixture of "green" plant material containing nitrogen, and "brown" plant material that is mostly cellulose (i.e. the main chemical component of wood). You then need to contain the mixture so that bacteria can break it down into chemicals that plants can use, and you need a large enough quantity of it so that it can reach high temperatures both the speed up the decomposition and to kill pathogens. The temperature can reach 50C or 120F in a fast-working compost pile.
The decomposition process takes several months to complete, or even years is the mix of "green" and "brown" plant material is not optimum. The mix of "green" and "brown" is important to provide the correct carbon-to-nitrogen ratio for the bacteria to process. Too much "brown" will not produce any composting activity, and too much "green" will create a wet anaerobic mess, which will rot down slowly, and probably smell terrible, instead of forming compost which is relatively dry and odour-free.
Animal food waste or waste dairy products is not necessary for traditional compost, and can be harmful if it attracts predators.
You can make "traditional" compost in a container (e.g. a plastic bin) rather than an outdoor heap of material, but you need a minimum volume of about 4 cubic feet (100 liters) for the process to work efficiently.
If you don't have the space, or a big enough supply of waste, for the traditional method to work properly, two alternatives (which you can do indoors) are a wormery, or the Japanese Bokashi system. Google for companies that supply the equipment to set up these systems.