The rules are not implicit; there are typically giant signs saying "RETURN CART HERE" over a metal cart corral that often contains other carts.
People are expected to learn this during their first or second trip to a grocery store that offers carts.
Similarly, at a full-service restaurant, you will be able to notice busboys picking up used tableware, and you will notice a scarcity of customer-accessible garbage bins (as compared to, say, a self-service fast-food restaurant).
If you are ever unsure of the protocol, you are always welcome to ask an employee. Employees at these businesses are typically distinguished by wearing a uniform.
Hope these tips help you on your future trips to Kroger/McDonald's/Olive Garden.