All of the melakhot that are permitted on Yom Tov are permitted only for the sake of Yom Tov; it is forbidden by Torah law to do melakha for weekday needs. Therefore, if one cooks toward the end of Yom Tov, such that the food will not be ready on Yom Tov, he violates Torah law, as he has cooked on Yom Tov for the weekday. If the food will be ready before the end of Yom Tov, he has not transgressed Torah law, since if guests arrive, he could serve them this food on Yom Tov. Thus it is not certain that he cooked for the weekday. However, if he intended to cook for the weekday, he violates rabbinic law (Beitza 17a; Rabba in Pesaḥim 46b; SA 503:1).
One may not cook on Yom Tov for Shabbat either, unless he made an eruv tavshilin (as explained below, 8:1).
Even activities that are not melakhot but still require effort, such as setting the table and washing the dishes, may not be done on Yom Tov for the weekday or for Shabbat (as explained in Peninei Halakha: Shabbat 22:15-16).
If one wants to fry schnitzel for a Yom Tov meal, he may make a bit extra to ensure that there will be enough, and he may then eat the leftovers after Yom Tov. However, he may not intentionally prepare extra in order to have leftovers for the week.
If one wants to heat water for a cup of tea or coffee, he may fill a large pot with water so that there will be hot water after Yom Tov. Similarly, one who wants to cook food may fill a large pot so that he will have leftovers after Yom Tov. Since he is placing the pot on the fire all at once, it is not forbidden to increase the quantities (marbeh be-shi’urim). Nevertheless, he should take care not to state explicitly that he is making extra for the weekday. Furthermore, once the pot has been placed on the fire, he may not add more food or water for the week (SA 503:2; MB ad loc. 15).
If there is a pot of food whose taste will be improved with the addition of more meat or fish, one may add them to the pot even after it has been placed on the fire, and even if he is mainly interested in having leftovers after Yom Tov, since he also wants to improve the Yom Tov meal (SA 503:1; MB ad loc. 6). (See 8:5 below regarding what one who forgot to make an eruv tavshilin may add to the pot on Yom Tov.)