A combinatorial identity. 
Let $n \in \mathbb N$ and $X_1,\ldots,X_n$ be subsets of $\{1,\ldots,n\}$ such that there is some $p$ such that $\forall i\in  \{1,\ldots,n\}, |X_i|=p$.
Suppose as well that there is some $q$ such that  $i\neq j \implies |X_i \cap X_j|=q$.
Prove that $p^2=p+(n-1)q$.

I tried something with an incidence matrix and it boils down to proving that its determinant is $p^2(p-q)^{(n-1)/2}$, but I can't prove that
EDIT: The problem as it is stated is flawed. It must be added that each $i$ appears in exactly $p$ of the $X_j$
 A: This is a proof for the case that each $i \in \{1,2,\ldots,n\}$ is contained in $p$ of the $X_j$. As pointed out in the comments, the result is not true in general otherwise.
Let us count the number of triplets $(i,j,k) \in \{1,2,\ldots,n\}^3$ with the property that $i \neq j$, $k \in X_i$ and $k \in X_j$.
Choosing $i$ and $j$ first and then choosing $k \in X_i \cap X_j$ can be done in $n(n-1)q$ ways.
Choosing $i$ first, then $k \in X_i$ and then $j$ such that $k \in X_j$ can be done in $np(p-1)$ ways, because $k$ is contained in $p-1$ sets other than $X_i$.
We conclude that both $n(n-1)q$ and $np(p-1)$ count the number of triplets, hence $n(n-1)q=np(p-1)$. This yields $(n-1)q = p(p-1)$, as desired.
A: I prove $p^2 \le p+(n-1)q$ in general and the equality holds if and only if @user133281's assumption is true:
Define a matrix $A =(a_{ij})$ where $a_{ij} = 1$ if $j \in X_i$ and otherwise $a_{ij} = 0$, then the given condition can be written as 
$$AA^{T} =  \left( \begin{array}{ccc}
p & q & \cdots & \cdots &q \\
q & p & q & \cdots & q  \\
\vdots & \vdots & \vdots & & \vdots \\
q & q & q & \cdots & p \end{array} \right) $$
Denote $b_i = \sharp\{j, i\in X_j\}$, then by multiplying both sides of the above matrix identity by the vector $v = (1,1,1,\cdots, 1)^T$ and computing the elements' sum of both results, we can show $$\sum_{i=1}^n b_i^2 = n(p+(n-1)q)$$
(Remark that $A^T v = (b_1, b_2, \cdots, b_n)^T$ and the elements of $A(b_1, b_2, \cdots, b_n)^T$ sums up to $\sum_{i=1}^n b_i^2$)
And obviously we also have $\sum_{i=1}^n b_i = np$. 
Since $(\sum_{i=1}^n b_i^2 )(n) \ge (\sum_{i=1}^n b_i )^2$, we have $ n^2(p+(n-1)q) \geq n^2p^2$, so $p^2 = p+(n-1)q$ if and only if all $b_i$'s are equal, i.e. $b_i = p, \forall i$
