"For both X and Y" or "both for X and Y" or ...?
As NOAD say: "When both is used in construction with and, the structures following 'both' and 'and' should be symmetrical in well-formed English."
In the first example, the symmetry or parallelism of 'for Y' and 'for Z' has been lost.
The second and the third example are well-formed English.
All three are acceptable and in use. The form that is selected might vary, depending on what X, Y, and Z are, how the sentence is punctuated, what verb is in the sentence, and what preposition is used (other prepositions could be used, besides for, such as to, by, or on).
"In the case of fixed capital, 1973-78 growth rates are close to 1973-76 rates both for total capital input and capital input per person potentially employed." (E.F. Denison)
X both for Y and Z
"At the primary level a higher proportion of female teachers means more enrollment and less failure for both boys and girls." (S.R. Khandker)
X for both Y and Z
"...meetings, and paper work, as well as significant expenses both for the initial incorporation and for any ultimate dissolution." (T. Crawford)
X both for Y and for Z