You want half the cookies, use half of each ingredient. There are some limitations to this analogy. Cookies are not exactly like chemical compounds. There are many different types of chocolate chip cookies in the universe, and many different types can be made by making slight variations or substitutions in the recipe given. For example, some cooks grind up some of their chocolate, leave the nuts out, use butter or applesauce for shortening substitutes.
Cookies are really mixtures.
The amount of each ingredient can be easily changed. There are multiple recipes that will produce acceptable tasty results. Compounds are said to have definite composition. The formula tells how many of each atom make up the compound. Each ingredient has its formula written as an element or a compound.