AutoPlay is a feature in Windows which was first introduced in Windows 98 and this feature checks newly discovered removable media and devices and, based on content such as pictures, music or video files, launches an appropriate application to play or display the content.
So when you insert a pen drive or connect a smartphone, Windows can execute certain tasks like opening file manager and this is where you can set the autoplay. In Windows 10, you can choose AutoPlay defaults from the settings.
Open the Settings menu and navigate to Devices-> AutoPlay.
In case AutoPlay is enabled and you want to disable it, you can do it from here. You can select what action you want to perform when you insert a removable drive, DVD (in case equipped) or memory card or smartphones.
You can either choose to take no action or open folder, ask me anytime or configure the drive for backup. If you have selected open folder, when you insert the pen drive, it will open the file explorer and show the files in the drive.