What do you have to do to buy a gun legally in Texas and Illinois?
You have to do two things when you purchase a firearm from a gun dealer (or any FFL) - you fill out an ATF form which asks certain questions (i.e. if you've been in a mental institute, if you've been convicted of violent felonies, etc.) and then the dealer does a background check with a database called the NICS to confirm whether you're allowed to purchase, aka whether they're legally allowed to "transfer" a firearm to you.
However, in many states this does not apply if you're buying off a private person that isn't an FFL or gun dealer. Meaning if say you and I both live in say Indiana or Wisconsin, I have a gun for sale, you want to buy it, I can sell it to you without having an FFL or doing any sort of checks, aside from technically I'm supposed to check your ID to confirm your a resident of the same state. This tends to be the case in a lot of the more conservative states whereas in other states it's more strict. Like in Illinois, if you want to buy a gun off me I first have to lookup your FOID card number to see that it's valid, which you can only get if you meet the federal and state guidelines.
At almost every gun show you'll have a group of Mexicans offering 50-100% more than the value that private sellers have for sale, especially ARs and AKs. Everyone knows where these guns would be headed once sold. Nonetheless, even though a private party can legally sell to them (after confirming their ID is from the same state i.e. Indiana), the vast majority will not because they don't want the trouble.
Most of the guns acquired in mass shootings tend to be legally sold because if the person passes all the checks like the guy in Texas, then the gun dealer can legally sell to them. These are people who buy guns with the expectation that they're going to commit a massacre and therefore don't care that the gun is going to be linked back to them since they already expected to do life in prison/die by cop.
On the other hand, the vast majority of shootings are perpetrated by people who acquired guns illegally. Those come from a variety of sources - home invasions, gun store robberies, crooked gun dealers, straw purchases, and increasingly now ghost guns.
Currently, you can be legal in one state and illegal if you cross the border.
Yeah well in that sense it's kind of like Russia as a federation. States like Chechnya are given a lot of leeway in their own laws, enforcement, etc. But yes, laws differ a lot between states here especially for things like firearms, gambling, marijuana and taxes. In general, the more conservative states are going to have stricter laws with gambling and marijuana, but more lax on firearms and lower taxes, while more liberal states tend to be lax on gambling and marijuana, but are strict with firearms and have higher taxes. The states that have the strictest gun laws actually have the most problems with murders, shootings, and crime in general.
Example - in Illinois, you can have an ounce of marijuana and I believe up to 4-5 plants for personal use and it's totally legal. There's gambling everywhere - almost every single gas station, diner, etc. has slots, joker poker, etc. machines. But gun laws are super strict, yet there's tons of crime. In Indiana/Wisconsin, two conservative states, an ounce of marijuana/4-5 plants will get you time. Gambling is restricted to certain establishments. Gun laws are lax, and there isn't nearly as much crime especially violent crime.