I believe that playstyle is easier to detect the higher rated the player gets because they've further developed their abilities and their tendencies have become more apparent. You have to play the needs of the chess position (as IM Jeremy Silman would say) and this is regardless of your playstyle. Every the tactical Tal would sometimes play positional endgames that looks like something Karpov may play. I see playstyle revealed less so in sparkling attacks or positional masterpieces, but rather more expressed in the routine junctures of decision-making.
Some chess positions have a clear "best move" or "best plan" and everything else is suboptimal, but playstyle shows itself when two routes are similarly winning (or similar evaluation), but the player chooses they one they feel better about (playstyle more than what is objectively "best").
Here's an example I invented just now:
p.s. For the players who like engine lines and claim Ke6 is best because it is checkmate in less moves with best play... then you may be missing the point. Unless you've calculated the Ke6 mate in 15 without the engine, then you don't get to proclaim what is optimal or not when you couldn't be bothered to calculate and do the work yourself. Both variations are equally winning. It is about minimizing risk, or playing what the player is more comfortable with and therefore less likely to blunder. Human players get nervous, calculate incorrectly, or see things incorrectly sometimes; computers just play the same unfeeling moves, so playing what is more comfortable has some merit... but only a tiny bit.
I have a hyper-aggressive playstyle (I throw all defense out the window and just attack), but how do I figure out what the playstyle of my friend is? Can I figure out whether my friend plays offensively or defensively? Everyone’s moves honestly look the same to me.