It should not be criminal to just enter the country. There would be no "illegal immigrants" if they were allowed or had the means to enter the country legally in the first place.
And you know how to make sure none of this stuff can happen to you? Simple - don't break immigration laws. It's really that simple. The law is there for a reason.