I heard it is usually better not routing at 90 degree angles. However what about with via, as I've read that it is usually recommended to use one layer for horizontal and another layer for vertical. Can I route safely like the picture below?
In low frequency designs, the "90 degree" rule is more of a manufacturing issue than an electrical one. Sharp bends can cause acid traps which can cause excessive etching. However in modern PCB manufacturing processes this is not an massive issue.
In high frequency, 90 degree bends cause a noticeable impedance mismatch (in fact 45 degree bends do as well, it's just not as pronounced) because at the corner the trace width changes to be 1.4x wider (think Pythagoras). However this is only really a concern when you start working with signals getting towards and above the GHz range.
From a signal integrity standpoint, whether or not you do the 90 degree bend before a via or do it "through the board" like you show, you will still have at least two 90 degree bends anyway. The trace has to bend 90 degrees into the board, and then bend 90 degree back on the other side. Given it is a cylinder, the 90 degree change in direction on the other side is irrelevant as its effectively a rotation inside the board.
Notice how in cross-section your via is effectively two 90 degree bends. The cross section of it doesn't change regardless of which direction your trace is exiting the via.
This is actually one of the reasons that you have to get very creative and use extreme care when making high frequency vias - and why they are best avoided in HF traces where possible.
You don't say anything about the useful frequency content of the signals on your traces, but given that they are clearly not controlled impedance, it is probably not all that high. In other words, you don't need to worry about what direction you exit the via.
Regardless of the frequency, don't limit yourself to just going horizontal on one layer and vertical on another. Where possible you might as well reduce the number of vias on a trace if for no other reason than vias take up space and make your design larger. For example if you have to go down then across then down again in a trace and there is nothing else in the way, just route the whole trace on the same layer.
Personally, I dont see any problem with your layout.
There are some people that suggest that a 90º right angle can generate reflections, but others dont. In both cases, angles will be much less important than the change in impedance with a new via.
In any case, it is something to do with high speed signals. In that case, there are many other issues to take into consideration as well, like the width of the traces, for example.