This paper addresses the application of self-supervised learning (SSL) to dependent data (e.g., time series, spatiotemporal data). Existing contrastive learning-based SSL methods assume semantic independence between samples, but this assumption fails for dependent data with complex correlations. Therefore, this paper presents a novel contrastive learning SSL theoretical framework tailored to continuous dependent data. We propose two ground truth similarity measures, "hard" and "soft" proximity, and based on these, derive an analytic form of the estimated similarity matrix that considers both types of proximity between samples, thereby presenting a loss function that takes dependency into account. The proposed method, Dependent TS2Vec, outperforms existing methods on both temporal and spatiotemporal subproblems, achieving 4.17% and 2.08% accuracy improvements on the UEA and UCR benchmarks, respectively, and a 7% higher ROC-AUC score on the drought classification task with complex spatiotemporal patterns.