Adding to the narrative in other answers,
here is a chart that might help further explain why brass players
tend to prefer sheet music written in keys with flats.
As shown, written keys that avoid the
“worst usual fingerings/positions” (elaborated below)
on common brass instruments (except French horn)
are overwhelmingly keys with flats.

<pre>
                                    Natural           Worst         Written keys WITHOUT
  Name of        Version of       (open) key          usual          the worst fingering
 instrument      instrument     ---------------     fingering/      ---------------------
  on score       considered     Concert Written      position         How many  How many
                                                                        flats    sharps

F French horn      4-rotor         F      C            2-3                  2,1  0  1,2
 Bb Trumpet        3-valve         Bb     "           1-2-3             4,3,2,1  0  1
Baritone T.C.         "            "      "             "               4,3,2,1  0  1
Eb Mellophone         "            Eb     "             "               4,3,2,1  0  1
Alto/Tenor horn       "            "      "             "               4,3,2,1  0  1
    Tuba            C tuba         C      "        1-2-3 / 2-4          4,3,2,1  0  1
    Tuba           Eb tuba         Eb     Eb            "           6,5,4,3,2       7,6
    Tuba           Bb tuba         Bb     Bb            "             5,4,3,2,1     7
Baritone horn      4-valve         "      "             "             5,4,3,2,1     7
  Euphonium           "            "      "             "             5,4,3,2,1     7
Baritone horn      3-valve         "      "           1-2-3           5,4,3,2,1     7
  Euphonium           "            "      "             "             5,4,3,2,1     7
  Trombone          slide          "      "            7th            5,4,3,2,1     7
  Trombone        F attach.        "      "            5th                3,2,1  0
</pre>

The &ldquo;worst usual fingering/position&rdquo;
is an ad hoc designation
likely to find agreement by many players due to these factors:
<br>&bullet;<sup><sup>&ensp;</sup></sup>
  The fingering/position is for a note
  in the usual scored range of the instrument.
<br>&bullet;<sup><sup>&ensp;</sup></sup>
  With 3 valves but no fingered slide,
  timbre is compromised when a note is lipped into tune.
<br>&bullet;<sup><sup>&ensp;</sup></sup>
  With 3 valves and a fingered tuning slide,
  coordinating the slide quickly is difficult.
<br>&bullet;<sup><sup>&ensp;</sup></sup>
  With an in-line 4th valve, pinkie-vs-ring-finger agility
  is anatomically limited.
<br>&bullet;<sup><sup>&ensp;</sup></sup>
  With a left-hand 4th valve, coordinating the hands quickly is difficult.
<br>&bullet;<sup><sup>&ensp;</sup></sup>
  On a trombone, a quick slide excursion is a gymnastic feat.
<br>
Admittedly: <sup><sup>&ensp;</sup></sup>
<br>&bullet;<sup><sup>&ensp;</sup></sup>
  The worst usual fingerings/positions of some instruments
  aren't as bad as those of others.
<br>&bullet;<sup><sup>&ensp;</sup></sup>
  Some rarer fingerings/positions are worse than those shown,
  but also tend to avoid flat keys.
<br>&bullet;<sup><sup>&ensp;</sup></sup>
  Almost-worst fingerings and convenient fingering sequences
  do play circumstantial roles as well.

The specific keys mentioned in the
question&hairsp;&mdash;&hairsp;A&flat; and E,
for B&flat; trumpet&mdash;&hairsp;are written
with 4 flats and 4 sharps, respectively.
If these keys are equally playable for you,
it is probably thanks to orchestral experience.
Trumpet key of A&flat; (concert G&flat;) is quite rare but should be
slightly more natural to play than trumpet key of E,
which is quite common as concert D in orchestral music.

<sub>
This comes from a community band and orchestra member
who fills for whatever non-percussion parts are needed during rehearsals,
playing the most appropriate brass instruments
that happen to be along or available.
</sub>