Why are some red items legal and others illegal?
All of the red items are categorized contraband, which is illegal and will get you in trouble with the police if they scan your ship and find any.
However...
Not all stations consider all types of contraband illegal. You may buy/sell contraband that is not illegal (your green arrows in the screenshot) at a particular station.
You cannot take any action with contraband that is illegal (other than taking it elsewhere that it).
Apparently it is the type of government that determines whether or not a certain type of contraband is illegal, according to this Reddit post. This post includes a small chart of which governments accept which contraband, although it is not complete unfortunately... It also seems to be in regards to Rebel Galaxy (not Outlaw), but the concept generally appies to both games.
Here's the chart from the above mentioned post: