If my laptop is locked, can a thumb drive be able to still infect my computer, or create a backdoor, or any other security risk if it's plugged into it. If so what are some example
Well technically yes, once somebody has a physical access virtually anything is possible. An example might be that you are running old version of windows with autoplay still on by default. Somebody then simply inserts the thumb drive with malicious autoplay data and there goes your security even though the computer is locked.
There are all sorts of opportunities to really impact a laptop or any physical machine if an attacker has direct access. A user can change the SAM database and provide themselves root/administrative access, or they could copy all your files out, they could use a Linux USB bootable device to embed an application script into your system. If the happen to should surf your password, they could login and use a rubber ducky to drop an exploit. An attacker with physical access is really hard to stop.
In corporate environments a lot of thought has to go into the types of security controls that go to defend a machine when it leaves. That's why there are a solutions for encrypting your OS, locking out BIOS, and remotely wiping machines that have been compromised/stolen. You never want your attackers to have your machine, but when they do end up with your machine you want to make it nearly impossible for them to actually do something with the machine.
This is a fairly large question, but you could google some basic things like "How to unlock a locked windows account." You could look up exploits that Kali Linux provides from a bootable USB. Try studying social engineering and how that might leave your machine vulnerable because of you. As you continue that research, you can determine what risks you think you need to worry about and which ones you can disregard.