We study the distribution of the statistics `number of fixed points' and `number of excedances' in permutations avoiding subsets of patterns of length 3. We solve all the cases of simultaneous avoidance of more than one pattern, giving generating functions enumerating these two statistics. Some cases are generalized to patterns of arbitrary length. For avoidance of one single pattern we give partial results. We also describe the distribution of these statistics in involutions avoiding any subset of patterns of length 3. The main technique is to use bijections between pattern-avoiding permutations and certain kinds of Dyck paths, in such a way that the statistics in permutations that we study correspond to statistics on Dyck paths that are easy to enumerate.