I’m assuming you entered ‘4’ when the program prompted you for “How many apples do you want”.
When using the * operator on strings, it just duplicates it a couple of times. Using the int() function, you can transform a string to a number. That’s why it works like that.
Open a Python REPL, and you can quickly play around with it: