The "Deflect" mechanic in Sekiro can be pretty precise - if you spam the button, it doesn't always work, but if you learn the timings as intended it can be 100% effective.
Just how precise is it, in terms of frames or seconds?
Per the Sekiro wiki on deflection, the default time window to deflect an enemy's attack is 12 frames. At 60 FPS, that's around 0.2 seconds. Tight, but not unachievably so.
I found a Youtube video that dives into the game files to verify. Technically, the game files specify deflection frame protection to last 6 frames, but that data is in 30 fps format, so doubling it gets us to 12 frames.
This frame window decreases if the player has recently just released their guard button. That decrease stacks, and the longer the player goes without a successful deflection, the smaller the window to deflect an attack becomes, down to a minimum of 0 frames. In other words, attempting to deflect when you're at the maximum penalty will result in deflection simply not working. This mechanic exists to prevent players from simply spamming the guard button to get away with imprecise deflection.
Successfully deflecting an attack resets that frame window decrease back to a 12 frame deflection window. Thus, successfully deflecting multiple attacks in a row imposes no penalty on the deflection window (and is used multiple times in-game against high attack speed enemies). This reset rewards players who successfully manage to deflect an attack, even if they might have been guard-spamming. The deflection frame window decrease is also reset if a period of 30 frames has passed without the player releasing the guard button, which, from my interpretation, is the game recognizing that you're simply no longer guard-spamming.
TL;DR:
The deflection window lasts for 12 frames (about 2 tenths of a second). This is lower, down to 0 frames (you will only block an attack and get chip damage, or get hit for full damage), if you're spamming the guard button and are not successfully deflecting.