TL;DR: "at school" and "in school" are basically the same. You won't get yourself into trouble by using them the same way. This is almost always true when the verb is "learn", except for one corner case that I'll discuss below.
The long answer is that "school" can have several different, but related, meanings, and sometimes it sounds better with one or the other preposition.
In the example sentences you gave, "school" is a metonym that refers to the act of attending classes at some institute of learning. So "things you'll never learn [at / in] school" are things you won't learn by attending classes at some institute of learning. Any time that's the intended meaning, it's correct to use either "at" or "in".
On the other hand, sometimes you say "at school" to mean the actual location where the learning takes place. In those cases you usually have to say "at school" and not "in school". If you literally mean that something is inside the school location, you'd usually say "in the school" or "in the school building".
The border between these two uses can be very fuzzy. For example:
"He's at school / He's in school."
If we say "He's at school", it implies Bob is at the school building (probably attending classes). If we say he's "in school", it means he's currently attending classes at an institute of learning. In the example I just gave, it doesn't matter, but then we have:
"What's Bob doing these days?"
"He's in school."
While not wrong, it sounds a bit odd to reply that he's "at school" in this example.
One more example, specific to "learn":
"He learned French in school" means he learned French from attending classes at an institute of learning.
"He learned French at school" can mean the same.
"He learned those bad habits at school" means the location where he learned bad habits was the school. Here "school" is the physical meaning. If we say "He learned those bad habits in school", then "school" is metonymy; it means that he learned bad habits from the process of attending classes. It strongly implies that the classes taught him the bad habits, whereas "He learned those bad habits at school" doesn't. The simplest way to understand this distinction is probably: If a professor taught him bad habits, he learned them "in school". If other kids or the janitor or random people who walked onto the campus taught him bad habits, he learned them "at school". If a professor taught him French, he learned it "in school" or "at school". If his French girlfriend taught him French, he learned it "at school". This is the only case I can think of where it makes a difference whether you learned it "in school" or "at school".