Whether you go through security or not depends on whether the local authorities "trust" the authorities of the origin airport to have done a good job or not (same rules, good testing, etc.).
If they trust them, then it's possible you could be able to get to your gate directly without going through security (provided the airport is designed for this, for your specific combination of flights -- some airport do not allow it at all, others will not allow it if you have to change terminals, and so on).
If they don't (which is the most frequent case I believe), then you will go through security before being allowed into the departures area.
Note that in this case, you usually (but not always) end up at a different security checkpoint used only for connecting passengers, not the main checkpoint used by all departing passengers. It typically means shorter queues, but not always.
Which countries trust which others is an ever changing situation. It's sometimes even more specific that just country pairs (IIRC there's an airport somewhere which trusts some flights from Japan but not all -- don't ask me why!).
In your case, if you had actually left the airside you would have gone through passport control twice (entering Germany and leaving it again), which I suppose you would remember, so you likely went through the connections security.
Glad to hear you got to your gate on time (even if barely). Note that when connections are tight there is often staff on hand at your arrival gate to escort you and possibly make you jump queues. You should also not hesitate to approach staff on your first flight if your connection is tight and/or the flight is late, they will be able to communicate with ground staff and let you know what to do (in some cases the airline will just decide upfront that you won't make it and rebook you on the next flight).
In any case, if the two flights are on the same ticket (not bought separately), then if you miss your connecting flights because of delays they will rebook you. On busy routes that means a delay of a few hours at most.